Skip to content

Instantly share code, notes, and snippets.

@lamarmarshall
Created January 17, 2018 04:21
Show Gist options
  • Save lamarmarshall/a399d12b10cc105238ade04cc856cdbe to your computer and use it in GitHub Desktop.
Save lamarmarshall/a399d12b10cc105238ade04cc856cdbe to your computer and use it in GitHub Desktop.
python multiprocessing manager / queue
import multiprocessing
def worker(dict, key, item):
dict[key] = item
if __name__ == '__main__':
mgr = multiprocessing.Manager()
dictionary = mgr.dict()
jobs = [multiprocessing.Process(target=worker, args=(dictionary, i, i*2)) \
for i in range(10)]
for j in jobs:
j.start()
for j in jobs:
j.join()
print(dictionary)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment