subprocess.Popen deadlocks

Lawrence D'Oliveiro ldo at geek-central.gen.new_zealand
Fri Nov 12 06:58:11 CET 2010


In message 
<2cf9a225-7d1c-4490-8a62-807e79bdd06a at n30g2000vbb.googlegroups.com>, 
eraserix wrote:

> I try to control several process from a python script. Each process is
> started from a thread, the threads just wait() for the child to exit
> and can then be joined. Main waits for SIGINT. After it received the
> signal, it will send a signal to the processes spawned by the threads
> and then join() the threads (which should terminate after their
> process exits)

Threading is always likely to be a source of bugs, whether in your code or 
the Python library. In this case, your threads don’t even seem to be doing 
anything useful.

Why not skip all the threads and just spawn all the processes in your main 
loop? Then after getting the SIGINT, send that signal to all your processes, 
and then do a bunch of os.waitpid calls to clean them all up.



More information about the Python-list mailing list