massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-pyright / node_modules / pyright / dist / typeshed-fallback / stdlib / multiprocessing / pool.pyi
1 import sys
2 from _typeshed import Self
3 from contextlib import AbstractContextManager
4 from typing import Any, Callable, Generic, Iterable, Iterator, List, Mapping, TypeVar
5
6 if sys.version_info >= (3, 9):
7     from types import GenericAlias
8
9 _PT = TypeVar("_PT", bound=Pool)
10 _S = TypeVar("_S")
11 _T = TypeVar("_T")
12
13 class ApplyResult(Generic[_T]):
14     if sys.version_info >= (3, 8):
15         def __init__(
16             self, pool: Pool, callback: Callable[[_T], None] | None, error_callback: Callable[[BaseException], None] | None
17         ) -> None: ...
18     else:
19         def __init__(
20             self,
21             cache: dict[int, ApplyResult[Any]],
22             callback: Callable[[_T], None] | None,
23             error_callback: Callable[[BaseException], None] | None,
24         ) -> None: ...
25     def get(self, timeout: float | None = ...) -> _T: ...
26     def wait(self, timeout: float | None = ...) -> None: ...
27     def ready(self) -> bool: ...
28     def successful(self) -> bool: ...
29     if sys.version_info >= (3, 9):
30         def __class_getitem__(cls, item: Any) -> GenericAlias: ...
31
32 # alias created during issue #17805
33 AsyncResult = ApplyResult
34
35 class MapResult(ApplyResult[List[_T]]):
36     if sys.version_info >= (3, 8):
37         def __init__(
38             self,
39             pool: Pool,
40             chunksize: int,
41             length: int,
42             callback: Callable[[list[_T]], None] | None,
43             error_callback: Callable[[BaseException], None] | None,
44         ) -> None: ...
45     else:
46         def __init__(
47             self,
48             cache: dict[int, ApplyResult[Any]],
49             chunksize: int,
50             length: int,
51             callback: Callable[[list[_T]], None] | None,
52             error_callback: Callable[[BaseException], None] | None,
53         ) -> None: ...
54
55 class IMapIterator(Iterator[_T]):
56     if sys.version_info >= (3, 8):
57         def __init__(self, pool: Pool) -> None: ...
58     else:
59         def __init__(self, cache: dict[int, IMapIterator[Any]]) -> None: ...
60     def __iter__(self: _S) -> _S: ...
61     def next(self, timeout: float | None = ...) -> _T: ...
62     def __next__(self, timeout: float | None = ...) -> _T: ...
63
64 class IMapUnorderedIterator(IMapIterator[_T]): ...
65
66 class Pool(AbstractContextManager[Pool]):
67     def __init__(
68         self,
69         processes: int | None = ...,
70         initializer: Callable[..., None] | None = ...,
71         initargs: Iterable[Any] = ...,
72         maxtasksperchild: int | None = ...,
73         context: Any | None = ...,
74     ) -> None: ...
75     def apply(self, func: Callable[..., _T], args: Iterable[Any] = ..., kwds: Mapping[str, Any] = ...) -> _T: ...
76     def apply_async(
77         self,
78         func: Callable[..., _T],
79         args: Iterable[Any] = ...,
80         kwds: Mapping[str, Any] = ...,
81         callback: Callable[[_T], None] | None = ...,
82         error_callback: Callable[[BaseException], None] | None = ...,
83     ) -> AsyncResult[_T]: ...
84     def map(self, func: Callable[[_S], _T], iterable: Iterable[_S], chunksize: int | None = ...) -> list[_T]: ...
85     def map_async(
86         self,
87         func: Callable[[_S], _T],
88         iterable: Iterable[_S],
89         chunksize: int | None = ...,
90         callback: Callable[[_T], None] | None = ...,
91         error_callback: Callable[[BaseException], None] | None = ...,
92     ) -> MapResult[_T]: ...
93     def imap(self, func: Callable[[_S], _T], iterable: Iterable[_S], chunksize: int | None = ...) -> IMapIterator[_T]: ...
94     def imap_unordered(
95         self, func: Callable[[_S], _T], iterable: Iterable[_S], chunksize: int | None = ...
96     ) -> IMapIterator[_T]: ...
97     def starmap(self, func: Callable[..., _T], iterable: Iterable[Iterable[Any]], chunksize: int | None = ...) -> list[_T]: ...
98     def starmap_async(
99         self,
100         func: Callable[..., _T],
101         iterable: Iterable[Iterable[Any]],
102         chunksize: int | None = ...,
103         callback: Callable[[_T], None] | None = ...,
104         error_callback: Callable[[BaseException], None] | None = ...,
105     ) -> AsyncResult[list[_T]]: ...
106     def close(self) -> None: ...
107     def terminate(self) -> None: ...
108     def join(self) -> None: ...
109     def __enter__(self: Self) -> Self: ...
110
111 class ThreadPool(Pool, AbstractContextManager[ThreadPool]):
112     def __init__(
113         self, processes: int | None = ..., initializer: Callable[..., Any] | None = ..., initargs: Iterable[Any] = ...
114     ) -> None: ...
115
116 # undocumented
117 if sys.version_info >= (3, 8):
118     INIT: str
119     RUN: str
120     CLOSE: str
121     TERMINATE: str
122 else:
123     RUN: int
124     CLOSE: int
125     TERMINATE: int