Race condition deadlock in communicate when threading?

Carl Banks pavlovevidence at gmail.com
Tue Sep 27 09:17:50 CEST 2011

There's really not enough information for us to debug this, but one possibility is that your subprocess is using buffered I/O; you're expecting the external task to write a string, but it doesn't actually write that string because it's sitting in a buffer.  First thing to try is to see if the program accepts some kind of command line argument to run in unbuffered mode (for instance, if you are calling a Python interpreter you can pass it the -u switch to force unbuffered I/O).  If (like most programs) it doesn't have an option to disable buffering, you can try running it on a pty device (if you're on Unix).  If worse comes to worst, see if there's a way to get the external task to print lots of extra output (a verbosity setting, for instance); that could work in a pinch until you can debug it more thoroughly.

Carl Banks

More information about the Python-list mailing list