mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-08 21:14:48 +08:00
Improve multiprocessing stubs (#8202)
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
This commit is contained in:
@@ -5,6 +5,8 @@ from collections.abc import Callable, Iterable, Sequence
|
||||
from ctypes import _CData
|
||||
from logging import Logger
|
||||
from multiprocessing import queues, synchronize
|
||||
from multiprocessing.connection import _ConnectionBase
|
||||
from multiprocessing.managers import SyncManager
|
||||
from multiprocessing.pool import Pool as _Pool
|
||||
from multiprocessing.process import BaseProcess
|
||||
from multiprocessing.sharedctypes import SynchronizedArray, SynchronizedBase
|
||||
@@ -42,12 +44,10 @@ class BaseContext:
|
||||
@staticmethod
|
||||
def active_children() -> list[BaseProcess]: ...
|
||||
def cpu_count(self) -> int: ...
|
||||
# TODO: change return to SyncManager once a stub exists in multiprocessing.managers
|
||||
def Manager(self) -> Any: ...
|
||||
# TODO: change return to Pipe once a stub exists in multiprocessing.connection
|
||||
def Pipe(self, duplex: bool = ...) -> Any: ...
|
||||
def Manager(self) -> SyncManager: ...
|
||||
def Pipe(self, duplex: bool = ...) -> tuple[_ConnectionBase, _ConnectionBase]: ...
|
||||
def Barrier(
|
||||
self, parties: int, action: Callable[..., Any] | None = ..., timeout: float | None = ...
|
||||
self, parties: int, action: Callable[..., object] | None = ..., timeout: float | None = ...
|
||||
) -> synchronize.Barrier: ...
|
||||
def BoundedSemaphore(self, value: int = ...) -> synchronize.BoundedSemaphore: ...
|
||||
def Condition(self, lock: _LockLike | None = ...) -> synchronize.Condition: ...
|
||||
@@ -61,7 +61,7 @@ class BaseContext:
|
||||
def Pool(
|
||||
self,
|
||||
processes: int | None = ...,
|
||||
initializer: Callable[..., Any] | None = ...,
|
||||
initializer: Callable[..., object] | None = ...,
|
||||
initargs: Iterable[Any] = ...,
|
||||
maxtasksperchild: int | None = ...,
|
||||
) -> _Pool: ...
|
||||
@@ -120,7 +120,10 @@ class BaseContext:
|
||||
@overload
|
||||
def get_context(self, method: str) -> BaseContext: ...
|
||||
|
||||
def get_start_method(self, allow_none: bool = ...) -> str: ...
|
||||
@overload
|
||||
def get_start_method(self, allow_none: Literal[False] = ...) -> str: ...
|
||||
@overload
|
||||
def get_start_method(self, allow_none: bool) -> str | None: ...
|
||||
def set_start_method(self, method: str | None, force: bool = ...) -> None: ...
|
||||
@property
|
||||
def reducer(self) -> str: ...
|
||||
|
||||
Reference in New Issue
Block a user