mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
bpo-40453: Add PyConfig._isolated_subinterpreter (GH-19820)
An isolated subinterpreter cannot spawn threads, spawn a child process or call os.fork(). * Add private _Py_NewInterpreter(isolated_subinterpreter) function. * Add isolated=True keyword-only parameter to _xxsubinterpreters.create(). * Allow again os.fork() in "non-isolated" subinterpreters.
This commit is contained in:
parent
8bcfd31cc0
commit
252346acd9
14 changed files with 68 additions and 12 deletions
|
@ -6243,9 +6243,10 @@ os_fork_impl(PyObject *module)
|
|||
/*[clinic end generated code: output=3626c81f98985d49 input=13c956413110eeaa]*/
|
||||
{
|
||||
pid_t pid;
|
||||
|
||||
if (_PyInterpreterState_GET() != PyInterpreterState_Main()) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "fork not supported for subinterpreters");
|
||||
PyInterpreterState *interp = _PyInterpreterState_GET();
|
||||
if (interp->config._isolated_interpreter) {
|
||||
PyErr_SetString(PyExc_RuntimeError,
|
||||
"fork not supported for isolated subinterpreters");
|
||||
return NULL;
|
||||
}
|
||||
if (PySys_Audit("os.fork", NULL) < 0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue