Using Python 2.6.1 on Mac OS X 10.6.2, I have the following problem:
I have a thread process (Thread class), and each of these threads has a channel (.Popen subprocess) something like:
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 pipe.communicate () code is blocking. Interestingly, when I sent an interrupt (e.g. Ctrl-CKeyboardInterrupt) to the parent process, it unlocks.
Interestingly, when I use class Worker(multiprocessing.Process), the code works fine.
Any thoughts on why this is blocking - and how to fix it will be greatly appreciated.
Thank.
source
share