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 roger.serwy
Recipients asvetlov, roger.serwy, terry.reedy
Date 2012-04-04.00:01:41
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1333497702.04.0.422171473435.issue14440@psf.upfronthosting.co.za>
In-reply-to
Content
Andrew, the reason the subprocess is not closing is due to a thread management problem. I found that a dummy thread handles cvar.wait() which is why the subprocess fails to terminate properly. 

If you change the tight loop in _getresponse to be:

    while myseq not in self.responses:
        print(threading.enumerate(), file=sys.__stderr__)
        sys.__stderr__.flush()
        cvar.wait(1)

Then you'll get the following dumped to the terminal once a second:
    [<_DummyThread(Dummy-1, started daemon 139991862630176)>, <Thread(SockThread, started daemon 139991766066944)>]

The MainThread already stopped, but these two daemon threads don't terminate, which is strange. Is this a bug in itself?

Polling the OS for the IDLE frontend process will give an indication to terminate the subprocess, but actually terminating the subprocess from within the subprocess is the main problem.

Attached is a patch which takes a different approach to terminating the subprocess by using .shutdown instead.
History
Date User Action Args
2012-04-04 00:01:42roger.serwysetrecipients: + roger.serwy, terry.reedy, asvetlov
2012-04-04 00:01:42roger.serwysetmessageid: <1333497702.04.0.422171473435.issue14440@psf.upfronthosting.co.za>
2012-04-04 00:01:41roger.serwylinkissue14440 messages
2012-04-04 00:01:41roger.serwycreate