title: Python: ulimit and nice for subprocess.call / subprocess.Popen?
body: <p>I need to limit the amount of time and cpu taken by external command line apps I spawn from a python process using subprocess.call , mainly because sometimes the spawned process gets stuck and pins the cpu at 99%. </p>
  
  <p>nice and ulimit seem like reasonable ways to do this, but I'm not sure how they'd interact with subprocess.</p>
  
  <ul>
  <li>The limits look something like:
  
  <ul>
  <li>Kill the process if it's taking more than 60 seconds</li>
  <li>Limit it to 20% of cpu</li>
  </ul></li>
  <li>I want to apply the resource limiting to the subprocess, not to the python process that's spawning the subprocesses.</li>
  </ul>
  
  <p>Is there a way to apply nice and ulimit to the subprocess.call spawned process? Are there better python-native alternatives?</p>
  
  <p>This is on a linux (ubuntu) system.</p>