Using Python 2.6.1 on Mac OS X 10.6.2, I've the following problem:
I have a threaded process (a Thread class), and each of those threads has a pipe (a subprocess.Popen) something likeso:
from threading import Thread
cmd = "some_cmd"
class Worker(Thread):
def run(self):
pipe = Popen(cmd,
stdin=PIPE,
stdout=PIPE,
stderr=PIPE)
out, err = pipe.communicate("some data")
The problem is that the pipe.communicate() code is blocking. Interestingly, when I sent an interrupt (e.g. Ctrl-C
KeyboardInterrupt) to the parent process then it unblocks.
Interestingly, when I use class Worker(multiprocessing.Process)
, the code works just fine.
Any thoughts as to why this is blocking - and how to fix it - would be greatly appreciated.
Thank you.