Skip to content

gh-113148: Handle exceptions from threading.atexit functions #130594

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

sergey-miryanov
Copy link
Contributor

@sergey-miryanov sergey-miryanov commented Feb 26, 2025

I have implemented proposed solution. Just add try/except and call threading excepthook.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
…exit
@sergey-miryanov
Copy link
Contributor Author

Please take a look.

@@ -1546,7 +1546,11 @@ def _shutdown():
# Call registered threading atexit functions before threads are joined.
# Order is reversed, similar to atexit.
for atexit_call in reversed(_threading_atexits):
atexit_call()
try:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we handle all exceptions there then test_atexit_after_shutdown fails. Maybe we should ignore specific exception from _register_atexit (that called from atexit handler)?

Copy link
Contributor Author

@sergey-miryanov sergey-miryanov Feb 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OTOH _register_atexit is private, so we can change its behavior. I don't see that b61b818 relying on this particular exception.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant