From 4a8a20f04e92ccc2d465958428ba055be10951dd Mon Sep 17 00:00:00 2001 From: Luka Sterbic Date: Mon, 19 Jun 2017 14:45:57 +0100 Subject: [PATCH] Allow passing lambdas as init arguments in multiprocessing (#1416) * Use NoReturn in multiprocessing init functions * Use Any for init functions --- stdlib/3/multiprocessing/context.pyi | 3 +-- stdlib/3/multiprocessing/managers.pyi | 2 +- stdlib/3/multiprocessing/pool.pyi | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/stdlib/3/multiprocessing/context.pyi b/stdlib/3/multiprocessing/context.pyi index f0b7dd5fa..bd1eed7f6 100644 --- a/stdlib/3/multiprocessing/context.pyi +++ b/stdlib/3/multiprocessing/context.pyi @@ -49,14 +49,13 @@ class BaseContext(object): def JoinableQueue(self, maxsize: int = ...) -> Any: ... # TODO: change return to SimpleQueue once a stub exists in multiprocessing.queues def SimpleQueue(self) -> Any: ... - # TODO: change return to Pool once a stub exists in multiprocessing.pool def Pool( self, processes: Optional[int] = ..., initializer: Optional[Callable[..., Any]] = ..., initargs: Tuple = ..., maxtasksperchild: Optional[int] = ... - ) -> Any: ... + ) -> multiprocessing.Pool: ... # TODO: typecode_or_type param is a ctype with a base class of _SimpleCData or array.typecode Need to figure out # how to handle the ctype # TODO: change return to RawValue once a stub exists in multiprocessing.sharedctypes diff --git a/stdlib/3/multiprocessing/managers.pyi b/stdlib/3/multiprocessing/managers.pyi index 00c72aabe..c2bad5b33 100644 --- a/stdlib/3/multiprocessing/managers.pyi +++ b/stdlib/3/multiprocessing/managers.pyi @@ -19,7 +19,7 @@ _Namespace = Namespace class BaseManager: def register(self, typeid: str, callable: Any = ...) -> None: ... def shutdown(self) -> None: ... - def start(self, initializer: Optional[Callable[..., None]] = ..., + def start(self, initializer: Optional[Callable[..., Any]] = ..., initargs: Iterable[Any] = ...) -> None: ... def __enter__(self) -> 'BaseManager': ... def __exit__(self, exc_type, exc_value, tb) -> None: ... diff --git a/stdlib/3/multiprocessing/pool.pyi b/stdlib/3/multiprocessing/pool.pyi index e4174b213..af9f9ebae 100644 --- a/stdlib/3/multiprocessing/pool.pyi +++ b/stdlib/3/multiprocessing/pool.pyi @@ -12,7 +12,7 @@ class AsyncResult(): class ThreadPool(): def __init__(self, processes: Optional[int] = None, - initializer: Optional[Callable[..., None]] = None, + initializer: Optional[Callable[..., Any]] = None, initargs: Iterable[Any] = ...) -> None: ... def apply(self, func: Callable[..., Any],