Skip to content
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

Send pending events on shutdown in 3.12 #2478

Closed
sentrivana opened this issue Nov 2, 2023 · 1 comment
Closed

Send pending events on shutdown in 3.12 #2478

sentrivana opened this issue Nov 2, 2023 · 1 comment
Assignees
Labels
enhancement New feature or request Python:3.12

Comments

@sentrivana
Copy link
Contributor

sentrivana commented Nov 2, 2023

Problem Statement

In Python 3.12 it's not possible to spawn new threads on interpreter shutdown. We patched our background worker that's responsible for sending events in an atexit hook to not attempt to send any pending events if it doesn't have an active thread in #2468.

Solution Brainstorm

Make the background worker aware that the interpreter is shutting down and if it doesn't have its own thread, make it use the main thread for sending any pending events. (Might not be possible.)

Or: Make the background worker always have a thread active?

@sentrivana sentrivana added enhancement New feature or request Python:3.12 labels Nov 2, 2023
@sentrivana sentrivana self-assigned this Nov 2, 2023
@sentrivana sentrivana changed the title Send pending events in main thread on shutdown in 3.12 Send pending events on shutdown in 3.12 Dec 6, 2023
@sentrivana
Copy link
Contributor Author

Based on my tests this solves a basically non existent problem. The worker creates a thread on demand. If there's any exception (transaction, etc.) happening, the thread will be created and can be reused during the atexit hook. The only scenario where I could see a potential issue is a program that runs event-free and then crashes -- we want that exception in Sentry --, but we also handle this case correctly as the thread is created before the atexit hook. Will close this.

@sentrivana sentrivana closed this as not planned Won't fix, can't repro, duplicate, stale Dec 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Python:3.12
Projects
None yet
1 participant