title: How to implement a subprocess timeout?
body: <p>I wan to implement a timeout on the child spawned by a subprocess call.</p>
  
  <p>So as a test:</p>
  
  <pre><code>#!/home/depot/.conda/envs/python3/bin/python
  import subprocess                                                     
  if __name__ == "__main__":
      subprocess.call('./sleep.py', timeout=1)
  </code></pre>
  
  <p>The <code>sleep.py</code> file being run:</p>
  
  <pre><code>#!/home/depot/.conda/envs/python36/bin/python
  from time import sleep
  
  if __name__ =="__main__":
       for j in range(3):
           print(j)
           sleep(1)
  </code></pre>
  
  <p>Now clearly this doesn't implement any timeout.</p>
  
  <p>I was a bit surprised as the doc seems to suggest that timeout is indeed an option in:<br>
  <a href="https://docs.python.org/3.4/library/subprocess.html#using-the-subprocess-module" rel="nofollow noreferrer">Using the subprocess Module</a>.</p>
  
  <p>However other answers on SO seems to disregard that functionality and advocate for the creation of a custom made timer:<br>
  <a href="https://stackoverflow.com/questions/37355136/subprocess-timeout-does-not-work">Subprocess timeout does not work</a><br>
  <a href="https://stackoverflow.com/questions/1191374/using-module-subprocess-with-timeout">Using module &#39;subprocess&#39; with timeout</a></p>
  
  <p>How is it possible to implement a timeout with the builtin <code>timeout</code> argument?</p>