Skip to content

Instantly share code, notes, and snippets.

@yattom
Created May 9, 2013 03:57
Show Gist options
  • Save yattom/5545452 to your computer and use it in GitHub Desktop.
Save yattom/5545452 to your computer and use it in GitHub Desktop.
a simple example of Python's multiprocessing
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