Skip to content

Send pending events on shutdown in 3.12 #2478

Closed as not planned
Closed as not planned

Description

@sentrivana

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?

Activity

  1. self-assigned this
    on Nov 2, 2023
  2. changed the title [-]Send pending events in main thread on shutdown in 3.12[/-] [+]Send pending events on shutdown in 3.12[/+] on Dec 6, 2023
  3. sentrivana commented on Dec 14, 2023

    @sentrivana
    CollaboratorAuthor

    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.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions