This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author giampaolo.rodola
Recipients giampaolo.rodola
Date 2013-11-30.15:53:32
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1385826813.77.0.0339260517434.issue19843@psf.upfronthosting.co.za>
In-reply-to
Content
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?
History
Date User Action Args
2013-11-30 15:53:33giampaolo.rodolasetrecipients: + giampaolo.rodola
2013-11-30 15:53:33giampaolo.rodolasetmessageid: <1385826813.77.0.0339260517434.issue19843@psf.upfronthosting.co.za>
2013-11-30 15:53:33giampaolo.rodolalinkissue19843 messages
2013-11-30 15:53:33giampaolo.rodolacreate