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
Crash when using typing and daemon threads #116514
When I run this code on Python 3.11 it runs fine, but if I import typing_minimal (or typing) in reader.py I get this error:
Fatal Python error: _enter_buffered_busy: could not acquire lock for <_io.BufferedReader name='<stdin>'> at interpreter shutdown, possibly due to daemon threads
Python runtime state: finalizing (tstate=0x00007fff13ab6960)
Current thread 0x00003944 (most recent call first):
<no Python frame>
fromsysimportstdinfromthreadingimportThread# BUG: I get an error when I assign this:# typing_minimal = __import__("typing_minimal")thread=Thread(target=lambda: stdin.buffer.read(), daemon=True)
Any idea why importing typing_minimal in reader.py makes a difference? __import__("typing_minimal") instead of typing_minimal = __import__("typing_minimal") works fine though.
Activity
sobolevn commentedon Mar 8, 2024
_lru_cache_wrapperusesRLock()inside, so this might be the cause when combined with a daemon thread.JelleZijlstra commentedon Mar 8, 2024
What is
typing_minimalhere? That's not in the stdlib and a cursory Google search didn't turn up anything.sobolevn commentedon Mar 8, 2024
It is a simplification of
typing.pyto make the bug more obvious :)JelleZijlstra commentedon Mar 8, 2024
It's in the comment... sorry I missed that.
nineteendo commentedon Mar 9, 2024
Any idea why importing
typing_minimalinreader.pymakes a difference?__import__("typing_minimal")instead oftyping_minimal = __import__("typing_minimal")works fine though.JelleZijlstra commentedon Mar 9, 2024
Possibly some new reference cycle gets created. Reminds me of #115874 though the symptom is different.
nineteendo commentedon Mar 13, 2024
Is there anything I can still help with?
sobolevn commentedon Mar 13, 2024
I used this example to reproduce the issue:
It still gives me:
So, now I think that this is a related to #113964
nineteendo commentedon Mar 13, 2024
The code at the top is simplified as much as possible. So this doesn't result in an error without the other changes (which is kind of strange too):
nineteendo commentedon Mar 13, 2024
This issue isn't so much about the interpreter crashing, but the fact that it crashes when I import
typing_minimalinreader.py.nineteendo commentedon Apr 10, 2024
JelleZijlstra commentedon Apr 10, 2024
It's a crash so it should be fixed. Hopefully someone will come along eventually and fix it, or other changes to the interpreter will fix this issue.