I used a python multiprocessor and am waiting for all processes using this code:
... results = [] for i in range(num_extract): url = queue.get(timeout=5) try: print "START PROCESS!" result = pool.apply_async(process, [host,url],callback=callback) results.append(result) except Exception,e: continue for r in results: r.get(timeout=7) ...
I try to use pool.join but I get an error:
Traceback (most recent call last): File "C:\workspace\sdl\lxchg\walker4.py", line 163, in <module> pool.join() File "C:\Python25\Lib\site-packages\multiprocessing\pool.py", line 338, in joi n assert self._state in (CLOSE, TERMINATE) AssertionError
Why join does not work? And what a good way to wait for all processes.
My second question is: how can I restart a specific process in a pool? I need this because of a memory leak. Now, in fact, I am rebuilding the entire pool after all the processes have completed their tasks (create a new pool of objects to restart the process).
What I need: for example, I have 4 processes in the pool. Then the process will receive its task, after completing the task I need to kill the process and start a new one (to update the memory leak).
python multiprocessing
Evg
source share