-
-
Notifications
You must be signed in to change notification settings - Fork 34.3k
Open
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-C-APItype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
The race condition is more easily noticed if site.py takes a while to execute as the internal "initialized" flag is set to 1 before the site import.
Example impact? PyO3 has to jump through some hoops to avoid problems here in embedding scenarios where multiple threads all want to use an interpreter (most often test suites, resulting in some flaky tests). PyO3/pyo3#5903
We document Py_IsInitialized() as safe to call at any time and as being accurate. It is technically safe, but it isn't currently accurate.
CPython versions tested on:
3.13, 3.14, 3.15-alpha
Linked PRs
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-C-APItype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error