Skip to content

Instantly share code, notes, and snippets.

@dulek
Created January 10, 2018 13:43
Show Gist options
  • Save dulek/e14f3bb10998477a58289f95d0edae9e to your computer and use it in GitHub Desktop.
Save dulek/e14f3bb10998477a58289f95d0edae9e to your computer and use it in GitHub Desktop.
import multiprocessing
import time
def foo(d, manager):
q = manager.Queue()
q.put('test')
d[0] = q
def bar(d, manager):
while 0 not in d:
time.sleep(1)
print d[0].get()
manager = multiprocessing.Manager()
d = manager.dict()
p = multiprocessing.Process(target=foo, args=(d, manager))
p2 = multiprocessing.Process(target=bar, args=(d, manager))
p.start()
p2.start()
p.join()
p2.join()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment