Subinterpreters running on the main thread should handle signals
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 77.2k
- Forks
- 35.9k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
Feature or enhancement
Proposal:
It's currently impossible to interrupt long-running operations inside subinterpreters:
from concurrent import interpreters
interp = interpreters.create()
interp.exec("import time; time.sleep(100)") # Cannot CTRL^C!
This is because _Py_ThreadCanHandleSignals explicitly requires the main interpreter:
After thinking about this for a while, I can't see any real reason why stdlib interpreters shouldn't be able to handle signals (in the main thread). It's probably a slight compatibility break for legacy C API subinterpreters, so we can just disable it for them (and add the new option to handle signals behind an interpreter configuration setting).
Has this already been discussed elsewhere?
No response given
Links to previous discussion of this feature:
Quickly discussed in-person a few months ago with @ericsnowcurrently and @colesbury. I don't think we came to a consensus, but there wasn't any pushback as far as I could tell.
Linked PRs
- gh-137174
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
Lies Include/internal/pycore_pystate.h bei _Py_ThreadCanHandleSignals sowie das concurrent.interpreters-Beispiel im Issue. Prüfe den verknüpften PR gh-137174, bevor du fortfährst; damit könnten lang laufende Operationen in Subinterpreterpreten im Main-Thread durch Ctrl-C unterbrochen werden, während die angegebene Legacy-C-API-Kompatibilität erhalten bleibt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- c, python
- Bereich
- operating-systems
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 25/100