title: python subprocess - detach a process
body: <p>I have a python script <code>af_audit_run.py</code>, and it calls another python script <code>request_audit.py</code> through <code>subprocess</code>.</p>
  <p>The second script <code>request_audit.py</code> invokes another subprocess in the background and returns a request id.</p>
  <p>The problem is the first script <code>af_audit_run.py</code>, which is supposed to exit soon after the second script returns the request id, is waiting for the entire background process to finish. Is there any way we can force the first script to exit as soon as the request id is returned?</p>
  <p><code>af_audit_run.py</code> -- waits for the result using the <code>communicate</code> method:</p>
  <pre><code>p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, 
  stderr=subprocess.PIPE)
  result, error = p.communicate()
  print(result.decode('utf-8'))
  print(error.decode('utf-8'))
  </code></pre>
  <p><code>request_audit.py</code> -- doesn't wait, just detaches a subprocess (3rd python script) and returns request id:</p>
  <pre><code>subprocess.Popen(cmd, shell=True, stdout=None, stderr=None, close_fds=True)
  print(request_id)
  </code></pre>
  <p>environment: Linux</p>