Created
May 9, 2013 03:57
-
-
Save yattom/5545452 to your computer and use it in GitHub Desktop.
a simple example of Python's multiprocessing
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
import multiprocessing | |
def f(num, d): | |
for i in range(100): | |
d['%d:%d'%(num, i)] = 1 | |
if __name__=='__main__': | |
ps = [] | |
m = multiprocessing.Manager() | |
d = m.dict() | |
for i in range(5): | |
p = multiprocessing.Process(target=f, args=(i, d)) | |
p.start() | |
ps.append(p) | |
for p in ps: p.join() | |
print d |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment