From 7f3e01550b2869575881f8bbe2c239604dbd4676 Mon Sep 17 00:00:00 2001 From: David Zbarsky Date: Wed, 17 Jan 2018 16:06:15 -0800 Subject: [PATCH] Add py2 stubs for multiprocessing.Queue (#1829) This is basically the same API as in Python 3. --- stdlib/2/multiprocessing/__init__.pyi | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/stdlib/2/multiprocessing/__init__.pyi b/stdlib/2/multiprocessing/__init__.pyi index 556d8cf75..74b5018a8 100644 --- a/stdlib/2/multiprocessing/__init__.pyi +++ b/stdlib/2/multiprocessing/__init__.pyi @@ -1,11 +1,29 @@ +from typing import Optional, TypeVar + from multiprocessing.process import Process as Process, current_process as current_process, active_children as active_children from multiprocessing.util import SUBDEBUG as SUBDEBUG, SUBWARNING as SUBWARNING +from Queue import Queue as _BaseQueue class ProcessError(Exception): ... class BufferTooShort(ProcessError): ... class TimeoutError(ProcessError): ... class AuthenticationError(ProcessError): ... +_T = TypeVar('_T') + +class Queue(_BaseQueue[_T]): + def __init__(self, maxsize: int = ...) -> None: ... + def get(self, block: bool = ..., timeout: Optional[float] = ...) -> _T: ... + def put(self, item: _T, block: bool = ..., timeout: Optional[float] = ...) -> None: ... + def qsize(self) -> int: ... + def empty(self) -> bool: ... + def full(self) -> bool: ... + def put_nowait(self, item: _T) -> None: ... + def get_nowait(self) -> _T: ... + def close(self) -> None: ... + def join_thread(self) -> None: ... + def cancel_join_thread(self) -> None: ... + def Manager(): ... def Pipe(duplex=True): ... def cpu_count() -> int: ... @@ -19,7 +37,6 @@ def Condition(lock=None): ... def Semaphore(value=1): ... def BoundedSemaphore(value=1): ... def Event(): ... -def Queue(maxsize=0): ... def JoinableQueue(maxsize=0): ... def Pool(processes=None, initializer=None, initargs=..., maxtasksperchild=None): ... def RawValue(typecode_or_type, *args): ...