multiprocessing.pool: fix __init__ methods (#5833)

Co-authored-by: hauntsaninja <>
This commit is contained in:
Shantanu
2021-08-28 12:04:08 -07:00
committed by GitHub
parent 670929e908
commit ba998cd5f9
2 changed files with 35 additions and 11 deletions

View File

@@ -1,6 +1,6 @@
import sys
from _typeshed import Self
from typing import Any, Callable, ContextManager, Generic, Iterable, Iterator, List, Mapping, TypeVar
from typing import Any, Callable, ContextManager, Dict, Generic, Iterable, Iterator, List, Mapping, TypeVar
if sys.version_info >= (3, 9):
from types import GenericAlias
@@ -10,12 +10,17 @@ _S = TypeVar("_S")
_T = TypeVar("_T")
class ApplyResult(Generic[_T]):
def __init__(
self,
pool: Pool,
callback: Callable[[_T], None] | None = ...,
error_callback: Callable[[BaseException], None] | None = ...,
) -> None: ...
if sys.version_info >= (3, 8):
def __init__(
self, pool: Pool, callback: Callable[[_T], None] | None, error_callback: Callable[[BaseException], None] | None
) -> None: ...
else:
def __init__(
self,
cache: Dict[int, ApplyResult[Any]],
callback: Callable[[_T], None] | None,
error_callback: Callable[[BaseException], None] | None,
) -> None: ...
def get(self, timeout: float | None = ...) -> _T: ...
def wait(self, timeout: float | None = ...) -> None: ...
def ready(self) -> bool: ...
@@ -26,9 +31,31 @@ class ApplyResult(Generic[_T]):
# alias created during issue #17805
AsyncResult = ApplyResult
class MapResult(ApplyResult[List[_T]]): ...
class MapResult(ApplyResult[List[_T]]):
if sys.version_info >= (3, 8):
def __init__(
self,
pool: Pool,
chunksize: int,
length: int,
callback: Callable[[List[_T]], None] | None,
error_callback: Callable[[BaseException], None] | None,
) -> None: ...
else:
def __init__(
self,
cache: Dict[int, ApplyResult[Any]],
chunksize: int,
length: int,
callback: Callable[[List[_T]], None] | None,
error_callback: Callable[[BaseException], None] | None,
) -> None: ...
class IMapIterator(Iterator[_T]):
if sys.version_info >= (3, 8):
def __init__(self, pool: Pool) -> None: ...
else:
def __init__(self, cache: Dict[int, IMapIterator[Any]]) -> None: ...
def __iter__(self: _S) -> _S: ...
def next(self, timeout: float | None = ...) -> _T: ...
def __next__(self, timeout: float | None = ...) -> _T: ...

View File

@@ -142,9 +142,6 @@ multiprocessing.managers.SyncManager.Event
multiprocessing.managers.SyncManager.Lock
multiprocessing.managers.SyncManager.Namespace
multiprocessing.managers.SyncManager.RLock
multiprocessing.pool.ApplyResult.__init__
multiprocessing.pool.IMapIterator.__init__
multiprocessing.pool.MapResult.__init__
multiprocessing.queues.JoinableQueue.__init__
multiprocessing.queues.Queue.__init__
multiprocessing.queues.Queue.put_nowait