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:
|
static inline int |
|
_Py_ThreadCanHandleSignals(PyInterpreterState *interp) |
|
{ |
|
return (_Py_IsMainThread() && _Py_IsMainInterpreter(interp)); |
|
} |
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
Feature or enhancement
Proposal:
It's currently impossible to interrupt long-running operations inside subinterpreters:
This is because
_Py_ThreadCanHandleSignalsexplicitly requires the main interpreter:cpython/Include/internal/pycore_pystate.h
Lines 82 to 86 in 7040aa5
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