title: Python subprocess module much slower than commands (deprecated)
body: <p>So I wrote a script that accesses a bunch of servers using nc on the command line, and originally I was using Python's commands module and calling commands.getoutput() and the script ran in about 45 seconds. Since commands is deprecated, I want to change everything over to using the subprocess module, but now the script takes 2m45s to run. Anyone have an idea of why this would be?</p>
  
  <p>What I had before:</p>
  
  <pre><code>output = commands.getoutput("echo get file.ext | nc -w 1 server.com port_num")
  </code></pre>
  
  <p>now I have </p>
  
  <pre><code>p = Popen('echo get file.ext | nc -w 1 server.com port_num', shell=True, stdout=PIPE)
  output = p.communicate()[0]
  </code></pre>
  
  <p>Thanks in advance for the help!</p>