Skip to content

Use critical sections in _warnings.c rather than mutex #160397

Open

Description

@nascheme

Feature or enhancement

Some advantages of critical sections:

  • when running this C code under the GIL-enabled build, no locking is required. A critical section is automatically a no-op there.
  • with a refactor, the regions holding the critical sections will be smaller and shorter. This improves performance and reduces chances of deadlocking.
  • we don't need a reset of the warnings mutex after fork (as done in GH-158974)
  • we don't have the issue of the mutex being held in daemon threads blocking shutdown (see GH-159485)

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

Linked PRs

Activity

  1. self-assigned this
    on Oct 22, 2026
  2. added a commit that references this issue on Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions