cpython/Lib/test/test_importlib
Gregory P. Smith 9a57179d74
GH-83065: Fix import deadlock by implementing hierarchical module locking (GH-137196)
Make _find_and_load() acquire the module locks for the full
dotted-name chain (parent before child) when loading a nested module, so
both threads contend on the same first lock and serialise instead of
deadlocking.

When acquiring a parent's lock would itself deadlock with another thread
that is loading that parent (cross-package circular imports), the parent's
lock is skipped and the partially-initialised parent is accepted -- the
same policy _lock_unlock_module() already applies on the existing code
path -- so concurrent circular imports that worked before continue to work.
2026-04-28 01:06:23 -07:00
..
builtin
extension
frozen
import_
metadata
namespace_pkgs
partial
resources
source
__init__.py
__main__.py
abc.py
test_abc.py
test_api.py
test_discover.py
test_lazy.py
test_locks.py
test_namespace_pkgs.py
test_pkg_import.py
test_spec.py
test_threaded_import.py
test_util.py
test_windows.py
threaded_import_hangers.py
util.py