Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion stdlib/multiprocessing/queues.pyi
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
import sys
from types import GenericAlias
from typing import Any, Generic, TypeVar
from typing import Any, Generic, NewType, TypeVar

__all__ = ["Queue", "SimpleQueue", "JoinableQueue"]

_T = TypeVar("_T")

_QueueState = NewType("_QueueState", object)
_JoinableQueueState = NewType("_JoinableQueueState", object)
_SimpleQueueState = NewType("_SimpleQueueState", object)

class Queue(Generic[_T]):
# FIXME: `ctx` is a circular dependency and it's not actually optional.
# It's marked as such to be able to use the generic Queue in __init__.pyi.
def __init__(self, maxsize: int = 0, *, ctx: Any = ...) -> None: ...
def __getstate__(self) -> _QueueState: ...
def __setstate__(self, state: _QueueState) -> None: ...
def put(self, obj: _T, block: bool = True, timeout: float | None = None) -> None: ...
def get(self, block: bool = True, timeout: float | None = None) -> _T: ...
def qsize(self) -> int: ...
Expand All @@ -24,13 +30,17 @@ class Queue(Generic[_T]):
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...

class JoinableQueue(Queue[_T]):
def __getstate__(self) -> _JoinableQueueState: ... # type: ignore[override]
def __setstate__(self, state: _JoinableQueueState) -> None: ... # type: ignore[override]
def task_done(self) -> None: ...
def join(self) -> None: ...

class SimpleQueue(Generic[_T]):
def __init__(self, *, ctx: Any = ...) -> None: ...
def close(self) -> None: ...
def empty(self) -> bool: ...
def __getstate__(self) -> _SimpleQueueState: ...
def __setstate__(self, state: _SimpleQueueState) -> None: ...
def get(self) -> _T: ...
def put(self, obj: _T) -> None: ...
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...