Python: Monitoring and killing/throttling spawned processes based on load, time, etc
<p>I have a queue of workers that spawn external third party apps using subprocess. I'd like to control how much of the overall resources of my server these process consume. Some of these external apps also tend to hang for unknown reasons, fixed with a restart.</p>

<p>What's a good way to:</p>

<ul>
<li>Monitor the overall server load (say, load average or equivalent of vmstat) in python?</li>
<li>Monitor the cpu load of the processes I spawn?</li>
<li>Kill processes I've spawned if they're taking too long or taking too much cpu?</li>
</ul>

<p>Basically I need to be able to control the load the I'm placing on my server with my spawned threads.</p>

<p>Hopefully there's a package or library that'll do all this for me?</p>
