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 threadsPython runtime state: finalizing (tstate=0x00007fff13ab6960)Current thread 0x00003944 (most recent call first):<no Python frame>
main.py:
import readerfrom typing_minimal import Generic, TypeVarclass BaseClass(Generic[TypeVar("VALUE")]): def __init__(self): passclass SubClass(BaseClass[None]): passreader.start_reading()
reader.py:
from sys import stdinfrom threading import Thread# BUG: I get an error when I uncomment this import:# import typing_minimaldef read(): stdin.buffer.read()def start_reading(): Thread(target=read, daemon=True).start()
typing_minimal.py:
from functools import lru_cache, wrapsdef _tp_cache(func): cached = lru_cache()(func) @wraps(func) def inner(*args, **kwds): return cached(*args, **kwds) return innerclass TypeVar: def __init__(self, _): passclass _GenericAlias: def __init__(self, origin): self.origin = origin def __eq__(self, other): if isinstance(other, _GenericAlias): return self.origin is other.origin return NotImplemented def __hash__(self): return hash(self.origin) def __mro_entries__(self, _): return (self.origin,)class Generic: @_tp_cache def __class_getitem__(cls, *_): return _GenericAlias(cls)
Does anyone have any idea what's going on here? I'm very confused.