You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Spawned-thread imports recurse in importlib _blocking_on bookkeeping #7586
Traceback (most recent call last):
File ".../Lib/collections/__init__.py", line 29, in <module>
import _collections_abc
File ".../Lib/_collections_abc.py", line 35, in <module>
from abc import ABCMeta, abstractmethod
File ".../Lib/abc.py", line 85, in <module>
from _abc import ...
File "_frozen_importlib", line 1368, in _find_and_load
File "_frozen_importlib", line 421, in __enter__
File "_frozen_importlib", line 311, in acquire
File "_frozen_importlib", line 170, in __enter__
RecursionError: in comparison
Narrowing
These succeed on a spawned VM thread:
direct dict.setdefault(...)
raw _weakref.ref(...)
import abc
import _collections_abc
These fail on a spawned VM thread:
import weakref
import collections
import array because it pulls in collections
The failure consistently lands in:
Lib/importlib/_bootstrap.py
_BlockingOnManager.__enter__()
_ModuleLock.acquire()
_blocking_on bookkeeping
Additional notes
This still reproduces when using vm.start_thread(...), so it is not just an arbitrary non-owner-thread embedding misuse.
Monkeypatch experiments suggest the bug is not just _WeakValueDictionary itself; the broader import-lock bookkeeping path seems to be involved.
Why this matters
I am working on a PyO3 frontend/backend split with a RustPython backend. A correct backend design needs a reliable spawned-thread/runtime-thread execution model, and this currently blocks that work.
Activity