title: Python: subprocess.Popen never returns
body: <p>I have written a Python script which runs some svn commands using <a href="http://docs.python.org/2/library/subprocess.html" rel="nofollow"><code>subprocess.Popen</code></a>. For example:</p>
  
  <pre><code>svn ls svn+ssh://url1/trunk
  svn cp svn+ssh://url1/trunk svn+ssh://url1/branch/1 --parents -m "blah"
  </code></pre>
  
  <p>For each command, I create an subprocess.Popen object:</p>
  
  
  
  <pre><code>p = subprocesp.Popen(cmd, shell=True, stdout=sp.PIPE, stderr=sp.STDOUT)
  </code></pre>
  
  <p>And wait for it to finish:</p>
  
  
  
  <pre><code>output      = p.communicate()[0].strip()
  return_code = p.returncode
  </code></pre>
  
  <p>The problem is that for some <code>svn cp</code> commands that fail immediately on the shell for copying inexistent repos, <strong><code>p.communicate()</code> never returns</strong>.</p>
  
  <p>Extra information:</p>
  
  <ul>
  <li>The code is executed using a thread pool (<code>multiprocessing.pool.ThreadPool</code>)</li>
  <li>The phenomena is menifested only for failing </li>
  <li>Using a shell, the exact same command finishes with error code 1 in less than two seconds.</li>
  </ul>
  
  <p>Any idea what am I missing here?</p>