]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-100227: Isolate the Import State to Each Interpreter (gh-101941)
authorEric Snow <ericsnowcurrently@gmail.com>
Thu, 9 Mar 2023 16:46:21 +0000 (09:46 -0700)
committerGitHub <noreply@github.com>
Thu, 9 Mar 2023 16:46:21 +0000 (09:46 -0700)
commitcf6e7c5e551b3513817d6a77ba88253dc8473298
treeca5e5125a1478a2cbc4c65e4467f8fcf7568f34f
parentb45d14b88611fefc6f054226d3e1117082d322c8
gh-100227: Isolate the Import State to Each Interpreter (gh-101941)

Specific changes:

* move the import lock to PyInterpreterState
* move the "find_and_load" diagnostic state to PyInterpreterState

Note that the import lock exists to keep multiple imports of the same module in the same interpreter (but in different threads) from stomping on each other.  Independently, we use a distinct global lock to protect globally shared import state, especially related to loaded extension modules.  For now we can rely on the GIL as that lock but with a per-interpreter GIL we'll need a new global lock.

The remaining state in _PyRuntimeState.imports will (probably) continue being global.

https://github.com/python/cpython/issues/100227
Include/cpython/import.h
Include/internal/pycore_import.h
Include/internal/pycore_runtime_init.h
Modules/posixmodule.c
Python/import.c