python / python/cpython

PyMutex re-entrancy not documented, confusing existing doc

Offen
#146,536 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

docs
Vorherrschende Sprache
Python
Sterne
77.2k
Forks
35.9k
PR-Merge-Kennzahlen
PR-Kennzahlen ausstehend

Beschreibung

Documentation

The doc for PyMutex is very unclear if the mutex is re-entrant. Can PyMutex_Lock be called multiple times in the same thread? Do there have to be an equal number of PyMutex_Unlock calls?

The PyMutex_Lock doc says it will succeed if the thread already has the lock. PyMutex_Unlock makes no mention of it having to be called in the same thread, or if any thread is okay.

Elsewhere it says the mutex is one byte, which is not enough to do any form of counting.

The relevance is that I have C code wrapping a library and that library can make callbacks. That means there are multiple paths through the call stack. A re-entrant counting mutex would work perfectly, and it is impossible to use a non-counted lock in that scenario, short of implementing another layer of locking to do the counting.

Linked PRs
  • gh-146543

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

Beginnen Sie mit der PyMutex-API-Referenz in der Dokumentation zur C-Synchronisierung und prüfen Sie den verknüpften PR gh-146543. Ermitteln Sie das dokumentierte Verhalten bei wiederholten Aufrufen von PyMutex_Lock sowie den erforderlichen Thread und die erforderliche Anzahl von Aufrufen für PyMutex_Unlock, und aktualisieren Sie anschließend die Dokumentation, sodass diese Regeln ausdrücklich festgehalten sind.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
c, python
Bereich
documentation
Issue-Typ
Dokumentation
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

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