massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-pyright / node_modules / pyright / dist / typeshed-fallback / stdlib / concurrent / futures / process.pyi
1 import sys
2 from collections.abc import Generator, Iterable, Mapping, MutableMapping, MutableSequence
3 from multiprocessing.connection import Connection
4 from multiprocessing.context import BaseContext, Process
5 from multiprocessing.queues import Queue, SimpleQueue
6 from threading import Lock, Semaphore, Thread
7 from types import TracebackType
8 from typing import Any, Callable, Generic, Tuple, TypeVar
9 from weakref import ref
10
11 from ._base import Executor, Future
12
13 _threads_wakeups: MutableMapping[Any, Any]
14 _global_shutdown: bool
15
16 class _ThreadWakeup:
17     _closed: bool
18     _reader: Connection
19     _writer: Connection
20     def __init__(self) -> None: ...
21     def close(self) -> None: ...
22     def wakeup(self) -> None: ...
23     def clear(self) -> None: ...
24
25 def _python_exit() -> None: ...
26
27 EXTRA_QUEUED_CALLS: int
28
29 _MAX_WINDOWS_WORKERS: int
30
31 class _RemoteTraceback(Exception):
32     tb: str
33     def __init__(self, tb: TracebackType) -> None: ...
34     def __str__(self) -> str: ...
35
36 class _ExceptionWithTraceback:
37     exc: BaseException
38     tb: TracebackType
39     def __init__(self, exc: BaseException, tb: TracebackType) -> None: ...
40     def __reduce__(self) -> str | Tuple[Any, ...]: ...
41
42 def _rebuild_exc(exc: Exception, tb: str) -> Exception: ...
43
44 _S = TypeVar("_S")
45
46 class _WorkItem(Generic[_S]):
47     future: Future[_S]
48     fn: Callable[..., _S]
49     args: Iterable[Any]
50     kwargs: Mapping[str, Any]
51     def __init__(self, future: Future[_S], fn: Callable[..., _S], args: Iterable[Any], kwargs: Mapping[str, Any]) -> None: ...
52
53 class _ResultItem:
54     work_id: int
55     exception: Exception
56     result: Any
57     def __init__(self, work_id: int, exception: Exception | None = ..., result: Any | None = ...) -> None: ...
58
59 class _CallItem:
60     work_id: int
61     fn: Callable[..., Any]
62     args: Iterable[Any]
63     kwargs: Mapping[str, Any]
64     def __init__(self, work_id: int, fn: Callable[..., Any], args: Iterable[Any], kwargs: Mapping[str, Any]) -> None: ...
65
66 if sys.version_info >= (3, 7):
67     class _SafeQueue(Queue[Future[Any]]):
68         pending_work_items: dict[int, _WorkItem[Any]]
69         shutdown_lock: Lock
70         thread_wakeup: _ThreadWakeup
71         if sys.version_info >= (3, 9):
72             def __init__(
73                 self,
74                 max_size: int | None = ...,
75                 *,
76                 ctx: BaseContext,
77                 pending_work_items: dict[int, _WorkItem[Any]],
78                 shutdown_lock: Lock,
79                 thread_wakeup: _ThreadWakeup,
80             ) -> None: ...
81         else:
82             def __init__(
83                 self, max_size: int | None = ..., *, ctx: BaseContext, pending_work_items: dict[int, _WorkItem[Any]]
84             ) -> None: ...
85         def _on_queue_feeder_error(self, e: Exception, obj: _CallItem) -> None: ...
86
87 def _get_chunks(*iterables: Any, chunksize: int) -> Generator[Tuple[Any, ...], None, None]: ...
88 def _process_chunk(fn: Callable[..., Any], chunk: tuple[Any, None, None]) -> Generator[Any, None, None]: ...
89 def _sendback_result(
90     result_queue: SimpleQueue[_WorkItem[Any]], work_id: int, result: Any | None = ..., exception: Exception | None = ...
91 ) -> None: ...
92
93 if sys.version_info >= (3, 7):
94     def _process_worker(
95         call_queue: Queue[_CallItem],
96         result_queue: SimpleQueue[_ResultItem],
97         initializer: Callable[..., None] | None,
98         initargs: Tuple[Any, ...],
99     ) -> None: ...
100
101 else:
102     def _process_worker(call_queue: Queue[_CallItem], result_queue: SimpleQueue[_ResultItem]) -> None: ...
103
104 if sys.version_info >= (3, 9):
105     class _ExecutorManagerThread(Thread):
106         thread_wakeup: _ThreadWakeup
107         shutdown_lock: Lock
108         executor_reference: ref[Any]
109         processes: MutableMapping[int, Process]
110         call_queue: Queue[_CallItem]
111         result_queue: SimpleQueue[_ResultItem]
112         work_ids_queue: Queue[int]
113         pending_work_items: dict[int, _WorkItem[Any]]
114         def __init__(self, executor: ProcessPoolExecutor) -> None: ...
115         def run(self) -> None: ...
116         def add_call_item_to_queue(self) -> None: ...
117         def wait_result_broken_or_wakeup(self) -> tuple[Any, bool, str]: ...
118         def process_result_item(self, result_item: int | _ResultItem) -> None: ...
119         def is_shutting_down(self) -> bool: ...
120         def terminate_broken(self, cause: str) -> None: ...
121         def flag_executor_shutting_down(self) -> None: ...
122         def shutdown_workers(self) -> None: ...
123         def join_executor_internals(self) -> None: ...
124         def get_n_children_alive(self) -> int: ...
125
126 _system_limits_checked: bool
127 _system_limited: bool | None
128
129 def _check_system_limits() -> None: ...
130 def _chain_from_iterable_of_lists(iterable: Iterable[MutableSequence[Any]]) -> Any: ...
131
132 if sys.version_info >= (3, 7):
133     from ._base import BrokenExecutor
134     class BrokenProcessPool(BrokenExecutor): ...
135
136 else:
137     class BrokenProcessPool(RuntimeError): ...
138
139 class ProcessPoolExecutor(Executor):
140     _mp_context: BaseContext | None = ...
141     _initializer: Callable[..., None] | None = ...
142     _initargs: Tuple[Any, ...] = ...
143     _executor_manager_thread: _ThreadWakeup
144     _processes: MutableMapping[int, Process]
145     _shutdown_thread: bool
146     _shutdown_lock: Lock
147     _idle_worker_semaphore: Semaphore
148     _broken: bool
149     _queue_count: int
150     _pending_work_items: dict[int, _WorkItem[Any]]
151     _cancel_pending_futures: bool
152     _executor_manager_thread_wakeup: _ThreadWakeup
153     _result_queue: SimpleQueue[Any]
154     _work_ids: Queue[Any]
155     if sys.version_info >= (3, 7):
156         def __init__(
157             self,
158             max_workers: int | None = ...,
159             mp_context: BaseContext | None = ...,
160             initializer: Callable[..., None] | None = ...,
161             initargs: Tuple[Any, ...] = ...,
162         ) -> None: ...
163     else:
164         def __init__(self, max_workers: int | None = ...) -> None: ...
165     if sys.version_info >= (3, 9):
166         def _start_executor_manager_thread(self) -> None: ...
167     def _adjust_process_count(self) -> None: ...