title: Difference between Popen.poll() and Popen.wait()
body: <p>I'm using the following command to run a shell command (creating a subprocess):</p>
  
  <pre><code>cmd = "ls"
  process = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True)
  </code></pre>
  
  <p>Then, I want to get its return code when it's finished. I should use <code>wait()</code> or <code>poll()</code>? It seems to me <code>wait()</code> is equal to a <code>poll()</code> enclosed in a busy wait. Something like:</p>
  
  <pre><code>while process.poll() == None:
      time.sleep(0.5)
  </code></pre>
  
  <p>I read that <code>wait()</code> could generate a deadlock if <code>stdout/stderr</code> buffer is filled. <code>process.poll()</code> used like above also could generate a deadlock? If this is true,
  I should use <code>process.comunicate()</code> to solve the problem? Nowadays, I only use
  <code>process.comunicate()</code> when I'm interested in the subprocess <code>stdout/stderr</code>.</p>
  
  <p>Thanks in advance.</p>