Add multiprocessing.pool to Python 2 stub (#1932)

This commit is contained in:
Takuya Akiba
2018-03-01 04:22:11 +09:00
committed by Jelle Zijlstra
parent e1243d0103
commit 7e169a29c2
2 changed files with 65 additions and 2 deletions

View File

@@ -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: ...

View File

@@ -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: ...