python / python/cpython

Some Runtime Finalization Constraints Are Not Enforced Nor Documented

Offen
#120,838 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

3.12 3.13 3.14 docs interpreter-core topic-C-API type-bug
Vorherrschende Sprache
Python
Sterne
77.2k
Forks
35.9k
PR-Merge-Kennzahlen
PR-Kennzahlen ausstehend

Beschreibung

Bug report

Bug description:

There are a few technical constraints on calling Py_Finalize() currently aren't enforced, well-documented, or widely recognized. This is partly due to the relatively small number of embedders and the even smaller number of them that might violate the constraints through the use of threads or subinterpreters.

The constraints are:

  • should be called only in the main thread
  • should be called only with the main interpreter active
  • should be called only using the same thread state used for Py_Initialize()

(That last one is potentially less critical.)

There are several reasons these matter:

  • the main thread of the main interpreter has a special role in the runtime's lifecycle
  • the main thread of the main interpreter has unique responsibilities that must be synchronized with finalization
  • conceptually, runtime lifecycle is an app-level function, and the app is typically driven through the "main" thread

The constraints should be documented, tested, and (possibly) enforced.

CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

Linked PRs
  • gh-120839
  • gh-120840
  • gh-120841
  • gh-120852
  • gh-120853
  • gh-121010
  • gh-121013
  • gh-121063

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne damit, den Einstiegspunkt Py_Finalize() nachzuverfolgen, und prüfe die verlinkten PRs gh-120839, gh-120840, gh-120841, gh-120852, gh-120853, gh-121010, gh-121013 und gh-121063. Als abgeschlossen gilt die Aufgabe, wenn die Einschränkungen für den Hauptthread, den Hauptinterpreter und den Threadzustand der Initialisierung dokumentiert, durch Tests abgedeckt und möglicherweise erzwungen werden.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
backend
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
20/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.