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 /Include | |
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 'Include')
-rw-r--r-- | Include/cpython/initconfig.h | 4 | ||||
-rw-r--r-- | Include/cpython/pylifecycle.h | 2 |
2 files changed, 6 insertions, 0 deletions
diff --git a/Include/cpython/initconfig.h b/Include/cpython/initconfig.h index 8326c23..df93a55 100644 --- a/Include/cpython/initconfig.h +++ b/Include/cpython/initconfig.h @@ -409,6 +409,10 @@ typedef struct { /* If equal to 0, stop Python initialization before the "main" phase */ int _init_main; + + /* If non-zero, disallow threads, subprocesses, and fork. + Default: 0. */ + int _isolated_interpreter; } PyConfig; PyAPI_FUNC(void) PyConfig_InitPythonConfig(PyConfig *config); diff --git a/Include/cpython/pylifecycle.h b/Include/cpython/pylifecycle.h index a01e9c9..eb523b8 100644 --- a/Include/cpython/pylifecycle.h +++ b/Include/cpython/pylifecycle.h @@ -65,6 +65,8 @@ PyAPI_FUNC(int) _Py_CoerceLegacyLocale(int warn); PyAPI_FUNC(int) _Py_LegacyLocaleDetected(int warn); PyAPI_FUNC(char *) _Py_SetLocaleFromEnv(int category); +PyAPI_FUNC(PyThreadState *) _Py_NewInterpreter(int isolated_subinterpreter); + #ifdef __cplusplus } #endif |