As of 3.12 `_lsprof` no longer calls `_PyEval_SetProfile` making `sys.getprofile()` useless with `cProfile`
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:
Starting in 3.12 with the addition of sys.monitoring, _lsprof, specifically in profiler_enable, no longer calls _PyEval_SetProfile.
Very specifically, this impacts previous functionality where python -m cProfile -m whatever would result in sys.setprofile() being called, and subsequently the whatever module could access the profiler object via sys.getprofile()
To my knowledge this is now completely impossible as sys.monitoring provides no meaningful way to access the profiler object.
In my particular use case, profiling could be enabled within the application, or if python -m cProfile was used, the existing profiler could be used allowing profiling to happen earlier than the enablement point of cProfile within the application.
Something to the effect of:
p = sys.getprofile()
if p is None:
p = cProfile.Profile()
p.enable()
CPython versions tested on:
3.13
Operating systems tested on:
Linux
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
Beginne damit, das Verhalten von _lsprof's profiler_enable und seine Beziehung zu _PyEval_SetProfile nachzuverfolgen, und vergleiche anschließend das Verhalten von python -m cProfile -m whatever in 3.11 und 3.12. Prüfe, wie sys.getprofile(), cProfile und sys.monitoring interagieren; die Aufgabe ist abgeschlossen, wenn das vorgesehene Profiler-Objekt zugänglich bleibt, ohne das Monitoring-Design ab 3.12 zu beeinträchtigen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- tooling
- Issue-Typ
- Bug
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100