Message263308
When no timeout is specified, these are the options as I see them:
1. SIGKILL child immediately on the first KeyboardInterrupt (Victor’s behaviour since 3.3)
2. Give up and leave a zombie after the first KeyboardInterrupt (pre-3.3 behaviour)
3. Wait again after first KeyboardInterrupt, and leave a zombie after the second one (Mike’s patch)
4. Ignore SIGINT so that by default no KeyboardInterrupt will happen, like C’s system()
5. Start a timeout after the first KeyboardInterrupt (Victor’s suggestion)
Here is my proposal, taking into account Victor’s desire to never leave a zombie, and Mike’s desire to let the child handle SIGINT in its own time: After the first KeyboardInterrupt or other exception, wait() a second time, and only use SIGKILL if the second wait() is interrupted. It’s a bit complicated, but I think this would solve everyone’s concerns raised so far:
def call(*popenargs, timeout=None, **kwargs):
p = Popen(*popenargs, **kwargs)
try:
if timeout is None:
try:
return p.wait()
except:
p.wait() # Let the child handle SIGINT
raise
else:
return p.wait(timeout=timeout)
except:
p.kill() # Last resort to avoid leaving a zombie
p.wait()
raise |
|
Date |
User |
Action |
Args |
2016-04-13 05:51:07 | martin.panter | set | recipients:
+ martin.panter, vstinner, SilentGhost, Mike Pomraning, rpcope1 |
2016-04-13 05:51:07 | martin.panter | set | messageid: <1460526667.21.0.129579155742.issue25942@psf.upfronthosting.co.za> |
2016-04-13 05:51:07 | martin.panter | link | issue25942 messages |
2016-04-13 05:51:07 | martin.panter | create | |
|