diff --git a/stdlib/2/multiprocessing/__init__.pyi b/stdlib/2/multiprocessing/__init__.pyi index 74b5018a8..d5c93250f 100644 --- a/stdlib/2/multiprocessing/__init__.pyi +++ b/stdlib/2/multiprocessing/__init__.pyi @@ -1,5 +1,6 @@ -from typing import Optional, TypeVar +from typing import Any, Callable, Optional, TypeVar, Iterable +from multiprocessing import pool 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 @@ -38,8 +39,12 @@ def Semaphore(value=1): ... def BoundedSemaphore(value=1): ... def Event(): ... def JoinableQueue(maxsize=0): ... -def Pool(processes=None, initializer=None, initargs=..., maxtasksperchild=None): ... def RawValue(typecode_or_type, *args): ... def RawArray(typecode_or_type, size_or_initializer): ... def Value(typecode_or_type, *args, **kwds): ... def Array(typecode_or_type, size_or_initializer, **kwds): ... + +def Pool(processes: Optional[int] = ..., + initializer: Optional[Callable[..., Any]] = ..., + initargs: Iterable[Any] = ..., + maxtasksperchild: Optional[int] = ...) -> pool.Pool: ... diff --git a/stdlib/2/multiprocessing/pool.pyi b/stdlib/2/multiprocessing/pool.pyi new file mode 100644 index 000000000..e444240b4 --- /dev/null +++ b/stdlib/2/multiprocessing/pool.pyi @@ -0,0 +1,58 @@ +# Stubs for multiprocessing.pool (Python 2) + +from typing import ( + Any, Callable, ContextManager, Iterable, Mapping, Optional, Dict, List, + TypeVar, +) + +_T = TypeVar('_T', bound='Pool') + +class AsyncResult(): + def get(self, timeout: float = ...) -> Any: ... + def wait(self, timeout: float = ...) -> None: ... + def ready(self) -> bool: ... + def successful(self) -> bool: ... + +class IMapIterator(Iterable[Any]): + def next(self, timeout: Optional[float] = ...) -> Any: ... + +class Pool(ContextManager[Pool]): + def __init__(self, processes: Optional[int] = ..., + initializer: Optional[Callable[..., None]] = ..., + initargs: Iterable[Any] = ..., + maxtasksperchild: Optional[int] = ...) -> None: ... + def apply(self, + func: Callable[..., Any], + args: Iterable[Any] = ..., + kwds: Dict[str, Any] = ...) -> Any: ... + def apply_async(self, + func: Callable[..., Any], + args: Iterable[Any] = ..., + kwds: Dict[str, Any] = ..., + callback: Optional[Callable[..., None]] = ...) -> AsyncResult: ... + def map(self, + func: Callable[..., Any], + iterable: Iterable[Any] = ..., + chunksize: Optional[int] = ...) -> List[Any]: ... + def map_async(self, func: Callable[..., Any], + iterable: Iterable[Any] = ..., + chunksize: Optional[int] = ..., + callback: Optional[Callable[..., None]] = ...) -> AsyncResult: ... + def imap(self, + func: Callable[..., Any], + iterable: Iterable[Any] = ..., + chunksize: Optional[int] = ...) -> IMapIterator: ... + def imap_unordered(self, + func: Callable[..., Any], + iterable: Iterable[Any] = ..., + chunksize: Optional[int] = ...) -> IMapIterator: ... + def close(self) -> None: ... + def terminate(self) -> None: ... + def join(self) -> None: ... + def __enter__(self: _T) -> _T: ... + +class ThreadPool(Pool, ContextManager[ThreadPool]): + + def __init__(self, processes: Optional[int] = ..., + initializer: Optional[Callable[..., Any]] = ..., + initargs: Iterable[Any] = ...) -> None: ...