KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm trying to learn how to use multiprocessing , and found the following example . I want to sum values as follows: from multiprocessing import Pool from time import time N = 10 K = 50 w = 0 def CostlyFunction(z): r = 0 for k in xrange(1, K+2): r += z ** (1 / k**1.5) print r w += r return r currtime = time() po = Pool() for i in xrange(N): po.apply_async(CostlyFunction,(i,)) po.close() po.join() print w print '2: parallel: time elapsed:', time() - currtime I can't get the sum of all r values.
Tags (comma-separated)
Save Edits
Cancel