Roger Serwy <roger.se...@gmail.com> added the comment:

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.

----------
Added file: http://bugs.python.org/file25112/issue14440_rev2.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue14440>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to