Skip to content

Instantly share code, notes, and snippets.

@ymmn
Created March 18, 2017 05:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ymmn/59bd6309330de205f2bff56ab2feb0e7 to your computer and use it in GitHub Desktop.
Save ymmn/59bd6309330de205f2bff56ab2feb0e7 to your computer and use it in GitHub Desktop.
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