Message204824
I recently implemented this in psutil and thought it would have been a nice addition for subprocess module as well:
https://code.google.com/p/psutil/issues/detail?id=440
Patch in attachment introduces a new subprocess.wait_procs() utility function which waits for multiple processes (Popen instances) to terminate.
The use case this covers is quote common: send SIGTERM to a list of processes, wait for them to terminate, send SIGKILL as last resort:
>>> def on_terminate(proc):
... print("process {} terminated".format(proc))
...
>>> for p in procs:
... p.terminate()
...
>>> gone, still_alive = wait_procs(procs, timeout=3, callback=on_terminate)
>>> for p in still_alive:
... p.kill()
Are we still in time for Python 3.4? |
|
Date |
User |
Action |
Args |
2013-11-30 15:53:33 | giampaolo.rodola | set | recipients:
+ giampaolo.rodola |
2013-11-30 15:53:33 | giampaolo.rodola | set | messageid: <1385826813.77.0.0339260517434.issue19843@psf.upfronthosting.co.za> |
2013-11-30 15:53:33 | giampaolo.rodola | link | issue19843 messages |
2013-11-30 15:53:33 | giampaolo.rodola | create | |
|