mirror of
https://github.com/python/cpython
synced 2026-09-29 12:10:30 +03:00
gh-114570: Add PythonFinalizationError exception (#115352)
Add PythonFinalizationError exception. This exception derived from RuntimeError is raised when an operation is blocked during the Python finalization. The following functions now raise PythonFinalizationError, instead of RuntimeError: * _thread.start_new_thread() * subprocess.Popen * os.fork() * os.fork1() * os.forkpty() Morever, _winapi.Overlapped finalizer now logs an unraisable PythonFinalizationError, instead of an unraisable RuntimeError.
This commit is contained in:
parent
326119d373
commit
3e7b7df5cb
13 changed files with 55 additions and 6 deletions
|
|
@ -1032,7 +1032,7 @@ subprocess_fork_exec_impl(PyObject *module, PyObject *process_args,
|
|||
|
||||
PyInterpreterState *interp = _PyInterpreterState_GET();
|
||||
if ((preexec_fn != Py_None) && interp->finalizing) {
|
||||
PyErr_SetString(PyExc_RuntimeError,
|
||||
PyErr_SetString(PyExc_PythonFinalizationError,
|
||||
"preexec_fn not supported at interpreter shutdown");
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1304,7 +1304,7 @@ do_start_new_thread(thread_module_state* state,
|
|||
return -1;
|
||||
}
|
||||
if (interp->finalizing) {
|
||||
PyErr_SetString(PyExc_RuntimeError,
|
||||
PyErr_SetString(PyExc_PythonFinalizationError,
|
||||
"can't create new thread at interpreter shutdown");
|
||||
return -1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ overlapped_dealloc(OverlappedObject *self)
|
|||
{
|
||||
/* The operation is still pending -- give a warning. This
|
||||
will probably only happen on Windows XP. */
|
||||
PyErr_SetString(PyExc_RuntimeError,
|
||||
PyErr_SetString(PyExc_PythonFinalizationError,
|
||||
"I/O operations still in flight while destroying "
|
||||
"Overlapped object, the process may crash");
|
||||
PyErr_WriteUnraisable(NULL);
|
||||
|
|
|
|||
|
|
@ -7841,7 +7841,7 @@ os_fork1_impl(PyObject *module)
|
|||
|
||||
PyInterpreterState *interp = _PyInterpreterState_GET();
|
||||
if (interp->finalizing) {
|
||||
PyErr_SetString(PyExc_RuntimeError,
|
||||
PyErr_SetString(PyExc_PythonFinalizationError,
|
||||
"can't fork at interpreter shutdown");
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -7885,7 +7885,7 @@ os_fork_impl(PyObject *module)
|
|||
pid_t pid;
|
||||
PyInterpreterState *interp = _PyInterpreterState_GET();
|
||||
if (interp->finalizing) {
|
||||
PyErr_SetString(PyExc_RuntimeError,
|
||||
PyErr_SetString(PyExc_PythonFinalizationError,
|
||||
"can't fork at interpreter shutdown");
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -8718,7 +8718,7 @@ os_forkpty_impl(PyObject *module)
|
|||
|
||||
PyInterpreterState *interp = _PyInterpreterState_GET();
|
||||
if (interp->finalizing) {
|
||||
PyErr_SetString(PyExc_RuntimeError,
|
||||
PyErr_SetString(PyExc_PythonFinalizationError,
|
||||
"can't fork at interpreter shutdown");
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue