`_PyEval_SetTrace` is no longer available in C API since 3.13
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 77.2k
- Forks
- 35.9k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
Bug report
Bug description:
Hello,
Prior 3.13 it was possible to set a trace in a specific thread from another thread by leveraging _PyEval_SetTrace, with pure Python. Now one can either set a trace for the current thread or all the threads using PyEval_SetTrace or PyEval_SetTraceAllThreads.
The change:
https://github.com/python/cpython/pull/108433/files#diff-9e7eb7e81667528dfa3a35bbf32fe622d4721c3c71385ea0ea2250abbd15d545R21
Interestingly, the profiling counterpart seems to be still available in the C API.
The use case I am interested in is a dedicated monitoring thread connected to a distributed observability system. This thread itself should not be traced as it manages tracing for the rest of the process.
Would it be possible to reinstate _PyEval_SetTrace back to the private C API?
Also, the new sys.monitoring module seems to offer a more high-level interface for debuggers and profilers, but it is unclear whether it is possible to limit the events to a certain thread. (unless of course one checks every event which does not seem efficient).
Alternatively, would writing an extension to expose this function be a better approach?
I would greatly appreciate any comments or suggestions regarding this. Thank you!
cc @vstinner
CPython versions tested on:
3.13
Operating systems tested on:
macOS
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Überprüfe die in PR 108433 beschriebene Entfernung und vergleiche die vorhandenen APIs PyEval_SetTrace und PyEval_SetTraceAllThreads mit dem angeforderten Verhalten pro Thread. Untersuche anschließend, ob sys.monitoring Ereignisse auf einen einzelnen Thread beschränken kann und ob eine Extension eine geeignete Alternative ist. Als erledigt gilt die Festlegung einer klaren API-Richtung mit Zustimmung der Maintainer zur Wiedereinführung oder zu einem anderen unterstützten Ansatz.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- c, python
- Bereich
- api, compilers
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 25/100