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 martin.panter
Recipients Mike Pomraning, SilentGhost, martin.panter, rpcope1, vstinner
Date 2016-04-13.05:51:07
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1460526667.21.0.129579155742.issue25942@psf.upfronthosting.co.za>
In-reply-to
Content
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
History
Date User Action Args
2016-04-13 05:51:07martin.pantersetrecipients: + martin.panter, vstinner, SilentGhost, Mike Pomraning, rpcope1
2016-04-13 05:51:07martin.pantersetmessageid: <1460526667.21.0.129579155742.issue25942@psf.upfronthosting.co.za>
2016-04-13 05:51:07martin.panterlinkissue25942 messages
2016-04-13 05:51:07martin.pantercreate