1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244
|
import sys
from collections.abc import Callable, Generator, Iterable, Mapping, MutableMapping, MutableSequence
from multiprocessing.connection import Connection
from multiprocessing.context import BaseContext, Process
from multiprocessing.queues import Queue, SimpleQueue
from threading import Lock, Semaphore, Thread
from types import TracebackType
from typing import Any, Generic, TypeVar, overload
from typing_extensions import TypeVarTuple, Unpack
from weakref import ref
from ._base import BrokenExecutor, Executor, Future
_T = TypeVar("_T")
_Ts = TypeVarTuple("_Ts")
_threads_wakeups: MutableMapping[Any, Any]
_global_shutdown: bool
class _ThreadWakeup:
_closed: bool
# Any: Unused send and recv methods
_reader: Connection[Any, Any]
_writer: Connection[Any, Any]
def close(self) -> None: ...
def wakeup(self) -> None: ...
def clear(self) -> None: ...
def _python_exit() -> None: ...
EXTRA_QUEUED_CALLS: int
_MAX_WINDOWS_WORKERS: int
class _RemoteTraceback(Exception):
tb: str
def __init__(self, tb: TracebackType) -> None: ...
class _ExceptionWithTraceback:
exc: BaseException
tb: TracebackType
def __init__(self, exc: BaseException, tb: TracebackType) -> None: ...
def __reduce__(self) -> str | tuple[Any, ...]: ...
def _rebuild_exc(exc: Exception, tb: str) -> Exception: ...
class _WorkItem(Generic[_T]):
future: Future[_T]
fn: Callable[..., _T]
args: Iterable[Any]
kwargs: Mapping[str, Any]
def __init__(self, future: Future[_T], fn: Callable[..., _T], args: Iterable[Any], kwargs: Mapping[str, Any]) -> None: ...
class _ResultItem:
work_id: int
exception: Exception
result: Any
if sys.version_info >= (3, 11):
exit_pid: int | None
def __init__(
self, work_id: int, exception: Exception | None = None, result: Any | None = None, exit_pid: int | None = None
) -> None: ...
else:
def __init__(self, work_id: int, exception: Exception | None = None, result: Any | None = None) -> None: ...
class _CallItem:
work_id: int
fn: Callable[..., Any]
args: Iterable[Any]
kwargs: Mapping[str, Any]
def __init__(self, work_id: int, fn: Callable[..., Any], args: Iterable[Any], kwargs: Mapping[str, Any]) -> None: ...
class _SafeQueue(Queue[Future[Any]]):
pending_work_items: dict[int, _WorkItem[Any]]
if sys.version_info < (3, 12):
shutdown_lock: Lock
thread_wakeup: _ThreadWakeup
if sys.version_info >= (3, 12):
def __init__(
self,
max_size: int | None = 0,
*,
ctx: BaseContext,
pending_work_items: dict[int, _WorkItem[Any]],
thread_wakeup: _ThreadWakeup,
) -> None: ...
elif sys.version_info >= (3, 9):
def __init__(
self,
max_size: int | None = 0,
*,
ctx: BaseContext,
pending_work_items: dict[int, _WorkItem[Any]],
shutdown_lock: Lock,
thread_wakeup: _ThreadWakeup,
) -> None: ...
else:
def __init__(
self, max_size: int | None = 0, *, ctx: BaseContext, pending_work_items: dict[int, _WorkItem[Any]]
) -> None: ...
def _on_queue_feeder_error(self, e: Exception, obj: _CallItem) -> None: ...
def _get_chunks(*iterables: Any, chunksize: int) -> Generator[tuple[Any, ...], None, None]: ...
def _process_chunk(fn: Callable[..., _T], chunk: Iterable[tuple[Any, ...]]) -> list[_T]: ...
if sys.version_info >= (3, 11):
def _sendback_result(
result_queue: SimpleQueue[_WorkItem[Any]],
work_id: int,
result: Any | None = None,
exception: Exception | None = None,
exit_pid: int | None = None,
) -> None: ...
else:
def _sendback_result(
result_queue: SimpleQueue[_WorkItem[Any]], work_id: int, result: Any | None = None, exception: Exception | None = None
) -> None: ...
if sys.version_info >= (3, 11):
def _process_worker(
call_queue: Queue[_CallItem],
result_queue: SimpleQueue[_ResultItem],
initializer: Callable[[Unpack[_Ts]], object] | None,
initargs: tuple[Unpack[_Ts]],
max_tasks: int | None = None,
) -> None: ...
else:
def _process_worker(
call_queue: Queue[_CallItem],
result_queue: SimpleQueue[_ResultItem],
initializer: Callable[[Unpack[_Ts]], object] | None,
initargs: tuple[Unpack[_Ts]],
) -> None: ...
if sys.version_info >= (3, 9):
class _ExecutorManagerThread(Thread):
thread_wakeup: _ThreadWakeup
shutdown_lock: Lock
executor_reference: ref[Any]
processes: MutableMapping[int, Process]
call_queue: Queue[_CallItem]
result_queue: SimpleQueue[_ResultItem]
work_ids_queue: Queue[int]
pending_work_items: dict[int, _WorkItem[Any]]
def __init__(self, executor: ProcessPoolExecutor) -> None: ...
def run(self) -> None: ...
def add_call_item_to_queue(self) -> None: ...
def wait_result_broken_or_wakeup(self) -> tuple[Any, bool, str]: ...
def process_result_item(self, result_item: int | _ResultItem) -> None: ...
def is_shutting_down(self) -> bool: ...
def terminate_broken(self, cause: str) -> None: ...
def flag_executor_shutting_down(self) -> None: ...
def shutdown_workers(self) -> None: ...
def join_executor_internals(self) -> None: ...
def get_n_children_alive(self) -> int: ...
_system_limits_checked: bool
_system_limited: bool | None
def _check_system_limits() -> None: ...
def _chain_from_iterable_of_lists(iterable: Iterable[MutableSequence[Any]]) -> Any: ...
class BrokenProcessPool(BrokenExecutor): ...
class ProcessPoolExecutor(Executor):
_mp_context: BaseContext | None
_initializer: Callable[..., None] | None
_initargs: tuple[Any, ...]
_executor_manager_thread: _ThreadWakeup
_processes: MutableMapping[int, Process]
_shutdown_thread: bool
_shutdown_lock: Lock
_idle_worker_semaphore: Semaphore
_broken: bool
_queue_count: int
_pending_work_items: dict[int, _WorkItem[Any]]
_cancel_pending_futures: bool
_executor_manager_thread_wakeup: _ThreadWakeup
_result_queue: SimpleQueue[Any]
_work_ids: Queue[Any]
if sys.version_info >= (3, 11):
@overload
def __init__(
self,
max_workers: int | None = None,
mp_context: BaseContext | None = None,
initializer: Callable[[], object] | None = None,
initargs: tuple[()] = (),
*,
max_tasks_per_child: int | None = None,
) -> None: ...
@overload
def __init__(
self,
max_workers: int | None = None,
mp_context: BaseContext | None = None,
*,
initializer: Callable[[Unpack[_Ts]], object],
initargs: tuple[Unpack[_Ts]],
max_tasks_per_child: int | None = None,
) -> None: ...
@overload
def __init__(
self,
max_workers: int | None,
mp_context: BaseContext | None,
initializer: Callable[[Unpack[_Ts]], object],
initargs: tuple[Unpack[_Ts]],
*,
max_tasks_per_child: int | None = None,
) -> None: ...
else:
@overload
def __init__(
self,
max_workers: int | None = None,
mp_context: BaseContext | None = None,
initializer: Callable[[], object] | None = None,
initargs: tuple[()] = (),
) -> None: ...
@overload
def __init__(
self,
max_workers: int | None = None,
mp_context: BaseContext | None = None,
*,
initializer: Callable[[Unpack[_Ts]], object],
initargs: tuple[Unpack[_Ts]],
) -> None: ...
@overload
def __init__(
self,
max_workers: int | None,
mp_context: BaseContext | None,
initializer: Callable[[Unpack[_Ts]], object],
initargs: tuple[Unpack[_Ts]],
) -> None: ...
if sys.version_info >= (3, 9):
def _start_executor_manager_thread(self) -> None: ...
def _adjust_process_count(self) -> None: ...
|