diff options
| author | Victor Stinner <vstinner@python.org> | 2020-05-01 11:33:44 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-05-01 11:33:44 +0200 |
| commit | 252346acd937ddba4845331994b8ff4f90349625 (patch) | |
| tree | 71d6298db81733d652abaa510c09ba90078efff0 /Lib | |
| parent | 8bcfd31cc01e068bca78aa42a87c24aea6ebc6b1 (diff) | |
| download | cpython-git-252346acd937ddba4845331994b8ff4f90349625.tar.gz | |
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 'Lib')
| -rw-r--r-- | Lib/test/test__xxsubinterpreters.py | 3 | ||||
| -rw-r--r-- | Lib/test/test_embed.py | 3 |
2 files changed, 5 insertions, 1 deletions
diff --git a/Lib/test/test__xxsubinterpreters.py b/Lib/test/test__xxsubinterpreters.py index 80eff19152..e17bfde2c2 100644 --- a/Lib/test/test__xxsubinterpreters.py +++ b/Lib/test/test__xxsubinterpreters.py @@ -794,6 +794,7 @@ class RunStringTests(TestBase): self.assertEqual(out, 'it worked!') def test_create_thread(self): + subinterp = interpreters.create(isolated=False) script, file = _captured_script(""" import threading def f(): @@ -804,7 +805,7 @@ class RunStringTests(TestBase): t.join() """) with file: - interpreters.run_string(self.id, script) + interpreters.run_string(subinterp, script) out = file.read() self.assertEqual(out, 'it worked!') diff --git a/Lib/test/test_embed.py b/Lib/test/test_embed.py index 0bdfae1b7e..3d60b2f330 100644 --- a/Lib/test/test_embed.py +++ b/Lib/test/test_embed.py @@ -406,6 +406,7 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase): 'check_hash_pycs_mode': 'default', 'pathconfig_warnings': 1, '_init_main': 1, + '_isolated_interpreter': 0, } if MS_WINDOWS: CONFIG_COMPAT.update({ @@ -766,6 +767,8 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase): 'check_hash_pycs_mode': 'always', 'pathconfig_warnings': 0, + + '_isolated_interpreter': 1, } self.check_all_configs("test_init_from_config", config, preconfig, api=API_COMPAT) |
