You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Multithreaded subinterpreters can be running during finalization #126016
Subinterpreters that are running in a different thread can still be running upon the finalization of the main interpreter, depending on what the thread was doing. Take the following script:
Yes, I know. The issue is that CTRL+C'ing causes the thread to not finish joining, meaning that the thread state is still marked as running. I'm working on a fix to properly clean up thread states before the interpreter shuts down using pending calls, but daemon threads will probably have to get addressed elsewhere (there's a data race, I think).
If you want, you can insert a signal catcher to catch SIGINT and do error handling on it. And in the error handling iterate over the list of threads and handle them
Activity
rruuaanng commentedon Oct 27, 2024
Using .join() will not trigger an assertion error. For the reason, please see the PR submitted by Eric and me.
ZeroIntensity commentedon Oct 27, 2024
Yes, I know. The issue is that CTRL+C'ing causes the thread to not finish joining, meaning that the thread state is still marked as running. I'm working on a fix to properly clean up thread states before the interpreter shuts down using pending calls, but daemon threads will probably have to get addressed elsewhere (there's a data race, I think).
rruuaanng commentedon Oct 27, 2024
If you want, you can insert a signal catcher to catch
SIGINTand do error handling on it. And in the error handling iterate over the list of threads and handle themZeroIntensity commentedon Oct 27, 2024
That would result in a thread safety nightmare if the thread was still running :)
ZeroIntensity commentedon Oct 27, 2024
#126026 addresses non-daemon threads. It's a bit hacky, though, because I have to manually mess with the status of the thread state.
ZeroIntensity commentedon Jan 11, 2025
I think #128640 will fix this as well.
gh-126016: Remove bad assertion in `PyThreadState_Clear` (GH-139158)
ZeroIntensity commentedon Sep 19, 2025
Closing this for now. Ideally we'll get to a point where we can add the assertion back, but that can be tracked elsewhere.
gh-126016: Fix flaky test by allowing the SIGINT return code (GH-139219)