Created
January 17, 2018 04:21
-
-
Save lamarmarshall/a399d12b10cc105238ade04cc856cdbe to your computer and use it in GitHub Desktop.
python multiprocessing manager / queue
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 | |
| 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