Skip to content

Commit ba998cd

Browse files
authored
multiprocessing.pool: fix __init__ methods (#5833)
Co-authored-by: hauntsaninja <>
1 parent 670929e commit ba998cd

File tree

2 files changed

+35
-11
lines changed

2 files changed

+35
-11
lines changed

stdlib/multiprocessing/pool.pyi

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import sys
22
from _typeshed import Self
3-
from typing import Any, Callable, ContextManager, Generic, Iterable, Iterator, List, Mapping, TypeVar
3+
from typing import Any, Callable, ContextManager, Dict, Generic, Iterable, Iterator, List, Mapping, TypeVar
44

55
if sys.version_info >= (3, 9):
66
from types import GenericAlias
@@ -10,12 +10,17 @@ _S = TypeVar("_S")
1010
_T = TypeVar("_T")
1111

1212
class ApplyResult(Generic[_T]):
13-
def __init__(
14-
self,
15-
pool: Pool,
16-
callback: Callable[[_T], None] | None = ...,
17-
error_callback: Callable[[BaseException], None] | None = ...,
18-
) -> None: ...
13+
if sys.version_info >= (3, 8):
14+
def __init__(
15+
self, pool: Pool, callback: Callable[[_T], None] | None, error_callback: Callable[[BaseException], None] | None
16+
) -> None: ...
17+
else:
18+
def __init__(
19+
self,
20+
cache: Dict[int, ApplyResult[Any]],
21+
callback: Callable[[_T], None] | None,
22+
error_callback: Callable[[BaseException], None] | None,
23+
) -> None: ...
1924
def get(self, timeout: float | None = ...) -> _T: ...
2025
def wait(self, timeout: float | None = ...) -> None: ...
2126
def ready(self) -> bool: ...
@@ -26,9 +31,31 @@ class ApplyResult(Generic[_T]):
2631
# alias created during issue #17805
2732
AsyncResult = ApplyResult
2833

29-
class MapResult(ApplyResult[List[_T]]): ...
34+
class MapResult(ApplyResult[List[_T]]):
35+
if sys.version_info >= (3, 8):
36+
def __init__(
37+
self,
38+
pool: Pool,
39+
chunksize: int,
40+
length: int,
41+
callback: Callable[[List[_T]], None] | None,
42+
error_callback: Callable[[BaseException], None] | None,
43+
) -> None: ...
44+
else:
45+
def __init__(
46+
self,
47+
cache: Dict[int, ApplyResult[Any]],
48+
chunksize: int,
49+
length: int,
50+
callback: Callable[[List[_T]], None] | None,
51+
error_callback: Callable[[BaseException], None] | None,
52+
) -> None: ...
3053

3154
class IMapIterator(Iterator[_T]):
55+
if sys.version_info >= (3, 8):
56+
def __init__(self, pool: Pool) -> None: ...
57+
else:
58+
def __init__(self, cache: Dict[int, IMapIterator[Any]]) -> None: ...
3259
def __iter__(self: _S) -> _S: ...
3360
def next(self, timeout: float | None = ...) -> _T: ...
3461
def __next__(self, timeout: float | None = ...) -> _T: ...

tests/stubtest_allowlists/py3_common.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,6 @@ multiprocessing.managers.SyncManager.Event
142142
multiprocessing.managers.SyncManager.Lock
143143
multiprocessing.managers.SyncManager.Namespace
144144
multiprocessing.managers.SyncManager.RLock
145-
multiprocessing.pool.ApplyResult.__init__
146-
multiprocessing.pool.IMapIterator.__init__
147-
multiprocessing.pool.MapResult.__init__
148145
multiprocessing.queues.JoinableQueue.__init__
149146
multiprocessing.queues.Queue.__init__
150147
multiprocessing.queues.Queue.put_nowait

0 commit comments

Comments
 (0)