python - Should I create a new Pool object every time or reuse a single one? -
i'm trying understand best practices python's multiprocessing.pool object.
in program use pool.imap frequently. every time start tasks in parallel create new pool object , close after i'm done.
i encountered hang number of tasks submitted pool less number of processes. odd occurred in test pipeline had bunch of things run before it. running test standalone did not cause hand. assume has making multiple pools.
i'd find resources me understand best practices in using python's multiprocessing. i'm trying understand implications of making several pool objects versus using one.
when create pool of worker processes, new processes spawned parent one. fast operation has cost.
therefore, long don't have reason, example pool breaks due 1 worker dying unexpectedly, it's better use same pool instance.
the reason hang hard tell without inspecting code. might not have clean previous instances (call close()/stop() , call join()). might have sent big data through pool channel ends deadlock , on.
surely pool not break if submit less tasks workers. pool designed de-couple number of tasks number of workers.
Comments
Post a Comment