python multiprocessing: why is process defunct after terminate?
multiprocessing, python, terminate, zombie-process
Solution
Try adding:
for pw in curWorkers:
pw.join()
at the end. `.terminate()` just kills the process. The parent process still needs to reap it (at least on Linux-y systems) before the child process goes away entirely.
Problem
I have some python multiprocessing code with the parent process starting a bunch of child worker processes and then terminating them after awhile: ``` from multiprocessing import Process nWorkers = 10 curWorkers = [] for iw in range(nWorkers): pq = Process(target=worker, args=(worker's_args_here)) pq.start() curWorkers.append(pq) # Do work here... for pw in curWorkers: pw.terminate() ``` However, the child processes all are showing as defunct long after termination. Are they zombie processes? More importantly, how should I terminate them so that they really go away?