Created
February 20, 2017 11:16
-
-
Save nickstenning/b6f9a6c5196a06cc3c67a367458506ab to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import multiprocessing | |
import time | |
def generate(queue, close): | |
queue.put_nowait('x' * 65523) | |
close.wait() | |
def main(): | |
q = multiprocessing.Queue() | |
close = multiprocessing.Event() | |
process = multiprocessing.Process(target=generate, args=(q, close)) | |
process.start() | |
time.sleep(1) | |
print("Sending close event") | |
close.set() | |
try: | |
print("Queue length: {:d}".format(q.qsize())) | |
except NotImplementedError: # Not available on OS X | |
pass | |
print("Joining enqueue process") | |
process.join() | |
print("Exited correctly") | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment