Improve multiprocessing stubs (#8202)

Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
This commit is contained in:
Alex Waygood
2022-07-01 19:20:39 +01:00
committed by GitHub
parent 7b54854c90
commit a2e8346d9a
8 changed files with 56 additions and 90 deletions

View File

@@ -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: ...