From 17cd91eeb3f20df48c2426c0e2006ccb22d16f5d Mon Sep 17 00:00:00 2001 From: Sean McLemon Date: Tue, 5 Mar 2019 14:52:02 +0100 Subject: [PATCH] multiprocessing.spawn submodule and multiprocessing.pool stubs (#2823) Added stub for multiprocessing.spawn submodule and updated multiprocessing.pool stub Closes #2758 --- stdlib/3/multiprocessing/__init__.pyi | 7 ++++--- stdlib/3/multiprocessing/pool.pyi | 13 +++++++++++-- stdlib/3/multiprocessing/spawn.pyi | 18 ++++++++++++++++++ 3 files changed, 33 insertions(+), 5 deletions(-) create mode 100644 stdlib/3/multiprocessing/spawn.pyi diff --git a/stdlib/3/multiprocessing/__init__.pyi b/stdlib/3/multiprocessing/__init__.pyi index c5e1e6e08..3356bb50a 100644 --- a/stdlib/3/multiprocessing/__init__.pyi +++ b/stdlib/3/multiprocessing/__init__.pyi @@ -6,13 +6,16 @@ from typing import ( ) from logging import Logger -from multiprocessing import connection, pool, synchronize +from multiprocessing import connection, pool, spawn, synchronize from multiprocessing.context import ( BaseContext, ProcessError as ProcessError, BufferTooShort as BufferTooShort, TimeoutError as TimeoutError, AuthenticationError as AuthenticationError) from multiprocessing.managers import SyncManager from multiprocessing.process import current_process as current_process from multiprocessing.queues import Queue as Queue, SimpleQueue as SimpleQueue, JoinableQueue as JoinableQueue +from multiprocessing.spawn import freeze_support as freeze_support +from multiprocessing.spawn import set_executable as set_executable + import sys # N.B. The functions below are generated at runtime by partially applying @@ -71,12 +74,10 @@ class Value(): def active_children() -> List[Process]: ... def allow_connection_pickling() -> None: ... def cpu_count() -> int: ... -def freeze_support() -> None: ... def get_logger() -> Logger: ... def log_to_stderr(level: Optional[Union[str, int]] = ...) -> Logger: ... def Manager() -> SyncManager: ... def set_forkserver_preload(module_names: List[str]) -> None: ... -def set_executable(executable: str) -> None: ... def get_all_start_methods() -> List[str]: ... def get_context(method: Optional[str] = ...) -> BaseContext: ... def get_start_method(allow_none: Optional[bool]) -> Optional[str]: ... diff --git a/stdlib/3/multiprocessing/pool.pyi b/stdlib/3/multiprocessing/pool.pyi index 49c7d9c20..469d83ad3 100644 --- a/stdlib/3/multiprocessing/pool.pyi +++ b/stdlib/3/multiprocessing/pool.pyi @@ -1,18 +1,22 @@ from typing import ( Any, Callable, ContextManager, Iterable, Mapping, Optional, List, - TypeVar, Generic, Iterator + Type, TypeVar, Generic, Iterator ) +from types import TracebackType _PT = TypeVar('_PT', bound='Pool') _S = TypeVar('_S') _T = TypeVar('_T') -class AsyncResult(Generic[_T]): +class ApplyResult(Generic[_T]): def get(self, timeout: Optional[float] = ...) -> _T: ... def wait(self, timeout: Optional[float] = ...) -> None: ... def ready(self) -> bool: ... def successful(self) -> bool: ... +# alias created during issue #17805 +AsyncResult = ApplyResult + _IMIT = TypeVar('_IMIT', bound=IMapIterator) class IMapIterator(Iterator[_T]): @@ -76,3 +80,8 @@ class ThreadPool(Pool, ContextManager[ThreadPool]): def __init__(self, processes: Optional[int] = ..., initializer: Optional[Callable[..., Any]] = ..., initargs: Iterable[Any] = ...) -> None: ... + +# undocumented +RUN: int +CLOSE: int +TERMINATE: int diff --git a/stdlib/3/multiprocessing/spawn.pyi b/stdlib/3/multiprocessing/spawn.pyi new file mode 100644 index 000000000..659253c48 --- /dev/null +++ b/stdlib/3/multiprocessing/spawn.pyi @@ -0,0 +1,18 @@ +from typing import Any, Dict, List, Mapping, Optional, Sequence +from types import ModuleType + +WINEXE: bool +WINSERVICE: bool + +def set_executable(exe: str) -> None: ... +def get_executable() -> str: ... +def is_forking(argv: Sequence[str]) -> bool: ... +def freeze_support() -> None: ... +def get_command_line(**kwds: Any) -> List[str]: ... +def spawn_main(pipe_handle: int, parent_pid: Optional[int] = ..., tracker_fd: Optional[int] = ...) -> None: ... +# undocumented +def _main(fd: int) -> Any: ... +def get_preparation_data(name: str) -> Dict[str, Any]: ... +old_main_modules: List[ModuleType] = ... +def prepare(data: Mapping[str, Any]) -> None: ... +def import_main_path(main_path: str) -> None: ...