Author vstinner
Recipients Mark.Shannon, davin, ned.deily, pitrou, serhiy.storchaka, vstinner
Date 2018-05-23.11:57:11
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1527076631.43.0.682650639539.issue33612@psf.upfronthosting.co.za>
In-reply-to
Content
> Yes, simply removing the assertion feels more like a copout than an actual fix.

We are very close to the 3.7rc1, so I suggest to remove the assertion, just to get more time to fix the issue.

--

I agree that in a perfect world, Python should cleanup everything properly, but in the current world, daemon threads and fork are a mess full of corner cases like this one.

Python doesn't join daemonic threads at shutdown, so I don't see how Python could ensure that the state of the Python state of these daemonic threads is consistent (ready to be cleared). For fork, it seems like the issue is similar. A fork removes immediately all threads except of the thread which called fork. How would it be possible for Python to ensure that the Python state of the other destroyed threads is consistent?

tstate->exc_info is a new feature of Python 3.7, to fix bpo-25612. But I don't think that Python 3.6 is better to cleanup daemon threads at shutdown or to cleanup threads on fork. If you run the attached bug.py with python3.6 -v bug.py, I also see warnings:

PyThreadState_Clear: warning: thread still has a frame
PyThreadState_Clear: warning: thread still has a frame
PyThreadState_Clear: warning: thread still has a frame
PyThreadState_Clear: warning: thread still has a frame
History
Date User Action Args
2018-05-23 11:57:11vstinnersetrecipients: + vstinner, pitrou, ned.deily, Mark.Shannon, serhiy.storchaka, davin
2018-05-23 11:57:11vstinnersetmessageid: <1527076631.43.0.682650639539.issue33612@psf.upfronthosting.co.za>
2018-05-23 11:57:11vstinnerlinkissue33612 messages
2018-05-23 11:57:11vstinnercreate