@@ -5,12 +5,14 @@ from multiprocessing.context import BaseContext, Process
55from multiprocessing .queues import Queue , SimpleQueue
66from threading import Lock , Semaphore , Thread
77from types import TracebackType
8- from typing import Any , Generic , TypeVar
8+ from typing import Any , Generic , TypeVar , overload
9+ from typing_extensions import TypeVarTuple , Unpack
910from weakref import ref
1011
1112from ._base import BrokenExecutor , Executor , Future
1213
1314_T = TypeVar ("_T" )
15+ _Ts = TypeVarTuple ("_Ts" )
1416
1517_threads_wakeups : MutableMapping [Any , Any ]
1618_global_shutdown : bool
@@ -109,17 +111,17 @@ if sys.version_info >= (3, 11):
109111 def _process_worker (
110112 call_queue : Queue [_CallItem ],
111113 result_queue : SimpleQueue [_ResultItem ],
112- initializer : Callable [... , object ] | None ,
113- initargs : tuple [Any , ... ],
114+ initializer : Callable [[ Unpack [ _Ts ]] , object ] | None ,
115+ initargs : tuple [Unpack [ _Ts ] ],
114116 max_tasks : int | None = None ,
115117 ) -> None : ...
116118
117119else :
118120 def _process_worker (
119121 call_queue : Queue [_CallItem ],
120122 result_queue : SimpleQueue [_ResultItem ],
121- initializer : Callable [... , object ] | None ,
122- initargs : tuple [Any , ... ],
123+ initializer : Callable [[ Unpack [ _Ts ]] , object ] | None ,
124+ initargs : tuple [Unpack [ _Ts ] ],
123125 ) -> None : ...
124126
125127if sys .version_info >= (3 , 9 ):
@@ -169,22 +171,61 @@ class ProcessPoolExecutor(Executor):
169171 _result_queue : SimpleQueue [Any ]
170172 _work_ids : Queue [Any ]
171173 if sys .version_info >= (3 , 11 ):
174+ @overload
172175 def __init__ (
173176 self ,
174177 max_workers : int | None = None ,
175178 mp_context : BaseContext | None = None ,
176- initializer : Callable [..., object ] | None = None ,
177- initargs : tuple [Any , ...] = (),
179+ initializer : Callable [[], object ] | None = None ,
180+ initargs : tuple [()] = (),
181+ * ,
182+ max_tasks_per_child : int | None = None ,
183+ ) -> None : ...
184+ @overload
185+ def __init__ (
186+ self ,
187+ max_workers : int | None = None ,
188+ mp_context : BaseContext | None = None ,
189+ * ,
190+ initializer : Callable [[Unpack [_Ts ]], object ],
191+ initargs : tuple [Unpack [_Ts ]],
192+ max_tasks_per_child : int | None = None ,
193+ ) -> None : ...
194+ @overload
195+ def __init__ (
196+ self ,
197+ max_workers : int | None ,
198+ mp_context : BaseContext | None ,
199+ initializer : Callable [[Unpack [_Ts ]], object ],
200+ initargs : tuple [Unpack [_Ts ]],
178201 * ,
179202 max_tasks_per_child : int | None = None ,
180203 ) -> None : ...
181204 else :
205+ @overload
206+ def __init__ (
207+ self ,
208+ max_workers : int | None = None ,
209+ mp_context : BaseContext | None = None ,
210+ initializer : Callable [[], object ] | None = None ,
211+ initargs : tuple [()] = (),
212+ ) -> None : ...
213+ @overload
182214 def __init__ (
183215 self ,
184216 max_workers : int | None = None ,
185217 mp_context : BaseContext | None = None ,
186- initializer : Callable [..., object ] | None = None ,
187- initargs : tuple [Any , ...] = (),
218+ * ,
219+ initializer : Callable [[Unpack [_Ts ]], object ],
220+ initargs : tuple [Unpack [_Ts ]],
221+ ) -> None : ...
222+ @overload
223+ def __init__ (
224+ self ,
225+ max_workers : int | None ,
226+ mp_context : BaseContext | None ,
227+ initializer : Callable [[Unpack [_Ts ]], object ],
228+ initargs : tuple [Unpack [_Ts ]],
188229 ) -> None : ...
189230 if sys .version_info >= (3 , 9 ):
190231 def _start_executor_manager_thread (self ) -> None : ...
0 commit comments