--- /dev/null
+from typing import (\r
+ Any, Callable, ContextManager, Iterable, Mapping, Optional, List,\r
+ TypeVar, Generic,\r
+)\r
+\r
+_PT = TypeVar('_PT', bound='Pool')\r
+_S = TypeVar('_S')\r
+_T = TypeVar('_T')\r
+\r
+class AsyncResult(Generic[_T]):\r
+ def get(self, timeout: Optional[float] = ...) -> _T: ...\r
+ def wait(self, timeout: Optional[float] = ...) -> None: ...\r
+ def ready(self) -> bool: ...\r
+ def successful(self) -> bool: ...\r
+\r
+_IMIT = TypeVar('_IMIT', bound=IMapIterator)\r
+\r
+class IMapIterator(Iterable[_T]):\r
+ def __iter__(self: _IMIT) -> _IMIT: ...\r
+ def next(self, timeout: Optional[float] = ...) -> _T: ...\r
+ def __next__(self, timeout: Optional[float] = ...) -> _T: ...\r
+\r
+class Pool(ContextManager[Pool]):\r
+ def __init__(self, processes: Optional[int] = ...,\r
+ initializer: Optional[Callable[..., None]] = ...,\r
+ initargs: Iterable[Any] = ...,\r
+ maxtasksperchild: Optional[int] = ...,\r
+ context: Optional[Any] = ...) -> None: ...\r
+ def apply(self,\r
+ func: Callable[..., _T],\r
+ args: Iterable[Any] = ...,\r
+ kwds: Mapping[str, Any] = ...) -> _T: ...\r
+ def apply_async(self,\r
+ func: Callable[..., _T],\r
+ args: Iterable[Any] = ...,\r
+ kwds: Mapping[str, Any] = ...,\r
+ callback: Optional[Callable[[_T], None]] = ...,\r
+ error_callback: Optional[Callable[[BaseException], None]] = ...) -> AsyncResult[_T]: ...\r
+ def map(self,\r
+ func: Callable[[_S], _T],\r
+ iterable: Iterable[_S] = ...,\r
+ chunksize: Optional[int] = ...) -> List[_T]: ...\r
+ def map_async(self, func: Callable[[_S], _T],\r
+ iterable: Iterable[_S] = ...,\r
+ chunksize: Optional[int] = ...,\r
+ callback: Optional[Callable[[_T], None]] = ...,\r
+ error_callback: Optional[Callable[[BaseException], None]] = ...) -> AsyncResult[List[_T]]: ...\r
+ def imap(self,\r
+ func: Callable[[_S], _T],\r
+ iterable: Iterable[_S] = ...,\r
+ chunksize: Optional[int] = ...) -> IMapIterator[_T]: ...\r
+ def imap_unordered(self,\r
+ func: Callable[[_S], _T],\r
+ iterable: Iterable[_S] = ...,\r
+ chunksize: Optional[int] = ...) -> IMapIterator[_T]: ...\r
+ def starmap(self,\r
+ func: Callable[..., _T],\r
+ iterable: Iterable[Iterable[Any]] = ...,\r
+ chunksize: Optional[int] = ...) -> List[_T]: ...\r
+ def starmap_async(self,\r
+ func: Callable[..., _T],\r
+ iterable: Iterable[Iterable[Any]] = ...,\r
+ chunksize: Optional[int] = ...,\r
+ callback: Optional[Callable[[_T], None]] = ...,\r
+ error_callback: Optional[Callable[[BaseException], None]] = ...) -> AsyncResult[List[_T]]: ...\r
+ def close(self) -> None: ...\r
+ def terminate(self) -> None: ...\r
+ def join(self) -> None: ...\r
+ def __enter__(self: _PT) -> _PT: ...\r
+\r
+\r
+class ThreadPool(Pool, ContextManager[ThreadPool]):\r
+\r
+ def __init__(self, processes: Optional[int] = ...,\r
+ initializer: Optional[Callable[..., Any]] = ...,\r
+ initargs: Iterable[Any] = ...) -> None: ...\r