stdlib: Add Shutdown error and shutdown method to queue module (#11489)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
This commit is contained in:
AN Long
2024-02-29 15:45:15 +08:00
committed by GitHub
parent 19d1b686b6
commit 555c1fe223

View File

@@ -12,6 +12,9 @@ _T = TypeVar("_T")
class Empty(Exception): ...
class Full(Exception): ...
if sys.version_info >= (3, 13):
class ShutDown(Exception): ...
class Queue(Generic[_T]):
maxsize: int
@@ -20,6 +23,8 @@ class Queue(Generic[_T]):
not_full: Condition # undocumented
all_tasks_done: Condition # undocumented
unfinished_tasks: int # undocumented
if sys.version_info >= (3, 13):
is_shutdown: bool # undocumented
# Despite the fact that `queue` has `deque` type,
# we treat it as `Any` to allow different implementations in subtypes.
queue: Any # undocumented
@@ -29,6 +34,9 @@ class Queue(Generic[_T]):
def full(self) -> bool: ...
def get(self, block: bool = True, timeout: float | None = None) -> _T: ...
def get_nowait(self) -> _T: ...
if sys.version_info >= (3, 13):
def shutdown(self, immediate: bool = False) -> None: ...
def _get(self) -> _T: ...
def put(self, item: _T, block: bool = True, timeout: float | None = None) -> None: ...
def put_nowait(self, item: _T) -> None: ...