title: Python calling pipe.communicate() in a thread
body: <p>Using Python 2.6.1 on Mac OS X 10.6.2, I've the following problem:</p>
  
  <p>I have a threaded process (a Thread class), and each of those threads has a pipe (a subprocess.Popen) something likeso:</p>
  
  <pre><code> 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")
  </code></pre>
  
  <p>The problem is that the pipe.communicate() code is blocking. Interestingly, when I sent an interrupt (e.g. <code>Ctrl-C</code> KeyboardInterrupt) to the parent process then it unblocks.</p>
  
  <p>Interestingly, when I use <code>class Worker(multiprocessing.Process)</code>, the code works just fine.</p>
  
  <p>Any thoughts as to why this is blocking <em>- and how to fix it -</em> would be greatly appreciated.</p>
  
  <p>Thank you.</p>