diff options
author | Victor Stinner <vstinner@python.org> | 2020-05-01 09:33:44 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-01 09:33:44 (GMT) |
commit | 252346acd937ddba4845331994b8ff4f90349625 (patch) | |
tree | 71d6298db81733d652abaa510c09ba90078efff0 /Modules/_threadmodule.c | |
parent | 8bcfd31cc01e068bca78aa42a87c24aea6ebc6b1 (diff) | |
download | cpython-252346acd937ddba4845331994b8ff4f90349625.zip cpython-252346acd937ddba4845331994b8ff4f90349625.tar.gz cpython-252346acd937ddba4845331994b8ff4f90349625.tar.bz2 |
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.
Diffstat (limited to 'Modules/_threadmodule.c')
-rw-r--r-- | Modules/_threadmodule.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Modules/_threadmodule.c b/Modules/_threadmodule.c index b3d90b2..77baba4 100644 --- a/Modules/_threadmodule.c +++ b/Modules/_threadmodule.c @@ -1085,6 +1085,14 @@ thread_PyThread_start_new_thread(PyObject *self, PyObject *fargs) "optional 3rd arg must be a dictionary"); return NULL; } + + PyInterpreterState *interp = _PyInterpreterState_GET(); + if (interp->config._isolated_interpreter) { + PyErr_SetString(PyExc_RuntimeError, + "thread is not supported for isolated subinterpreters"); + return NULL; + } + boot = PyMem_NEW(struct bootstate, 1); if (boot == NULL) return PyErr_NoMemory(); |