classification
Title: [subinterpreters] Add PyConfig._isolated_interpreter: isolated subinterpreters
Type: Stage: resolved
Components: Subinterpreters Versions: Python 3.9
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: barry, corona10, eric.snow, vstinner
Priority: normal Keywords: patch

Created on 2020-04-30 20:00 by vstinner, last changed 2021-09-21 20:05 by vstinner. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 19820 merged vstinner, 2020-04-30 20:07
Messages (3)
msg367778 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-04-30 20:00
I propose to add PyConfig._isolated_interpreter configuration parameter to disallow threads, subprocesses and fork in a subinterpreter.

_xxsubinterpreter.create() gets a new keyword-only isolated=True parameter to opt-in for not isolated mode, which is the current behavior of Py_NewInterpreter(). For example, mod_wsgi would continue to run in "non isolated" mode.

Attached PR implements this change. With the change, os.fork() is allowed again in "non isolated" subinterpreters (like mod_wsgi). os.fork() was disallowed in subinterpreters in Python 3.8, but subprocess was still allowed.
msg367830 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-05-01 09:33
New changeset 252346acd937ddba4845331994b8ff4f90349625 by Victor Stinner in branch 'master':
bpo-40453: Add PyConfig._isolated_subinterpreter (GH-19820)
https://github.com/python/cpython/commit/252346acd937ddba4845331994b8ff4f90349625
msg367831 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-05-01 09:34
TODO

* check that spawning a thread is blocked in isolated subinterpreter
* block loading C extensions which don't implement PEP 489 in isolated subinterpreter

(see https://github.com/python/cpython/pull/19820 comments)
History
Date User Action Args
2021-09-21 20:05:07vstinnersetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2020-05-15 00:39:34vstinnersetcomponents: + Subinterpreters, - Interpreter Core
title: Add PyConfig._isolated_interpreter: isolated subinterpreters -> [subinterpreters] Add PyConfig._isolated_interpreter: isolated subinterpreters
2020-05-01 14:55:45eric.snowsetnosy: + eric.snow
2020-05-01 10:56:40corona10setnosy: + corona10
2020-05-01 09:34:43vstinnersetmessages: + msg367831
2020-05-01 09:33:51vstinnersetmessages: + msg367830
2020-04-30 22:09:25barrysetnosy: + barry
2020-04-30 20:07:59vstinnersetkeywords: + patch
stage: patch review
pull_requests: + pull_request19140
2020-04-30 20:00:57vstinnercreate