Created
March 18, 2017 05:42
-
-
Save ymmn/59bd6309330de205f2bff56ab2feb0e7 to your computer and use it in GitHub Desktop.
This file contains 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
from multiprocessing import Process, Queue | |
import time | |
import os | |
def worker(q, output_q): | |
while True: | |
print 'im the worker', os.getpid() | |
print 'got ', q.get() | |
output_q.put(55) | |
time.sleep(1) | |
q = Queue() | |
output_q = Queue() | |
q.put([42, None, 'hello']) | |
p = Process(target=worker, args=(q, output_q)) | |
p.start() | |
while True: | |
print 'im the master', os.getpid() | |
print 'giving you more stuff in your queue' | |
q.put(42) | |
print 'master got back', output_q.get() | |
time.sleep(5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment