Keep order while using multiprocessing in Python -
Please note how I can place commands while using multiprocessing in Python. Thanks to both the fanks and some fader returns lists,
result = [] def callback (* args): results.append (* args) def in_parallel (fn, func): print process started ', For time.strftime ('% H:% M:% S ') pool = mp.Pool (processes = 4) num, I calculate (somefunc (fn)): pool.apply_async (func, args = ( I,), callback = callback ([num, callback])) pool.close () pool.join () Return results
The problem is resolved with:
r = pool.map_async (...) r.wait ()
Comments
Post a Comment