mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-22 20:01:29 +08:00
Re-organize directory structure (#4971)
See discussion in #2491 Co-authored-by: Ivan Levkivskyi <ilevkivskyi@dropbox.com>
This commit is contained in:
87
stdlib/multiprocessing/__init__.pyi
Normal file
87
stdlib/multiprocessing/__init__.pyi
Normal file
@@ -0,0 +1,87 @@
|
||||
import sys
|
||||
from logging import Logger
|
||||
from multiprocessing import connection, pool, sharedctypes, synchronize
|
||||
from multiprocessing.context import (
|
||||
AuthenticationError as AuthenticationError,
|
||||
BaseContext,
|
||||
BufferTooShort as BufferTooShort,
|
||||
DefaultContext,
|
||||
Process as Process,
|
||||
ProcessError as ProcessError,
|
||||
SpawnContext,
|
||||
TimeoutError as TimeoutError,
|
||||
)
|
||||
from multiprocessing.managers import SyncManager
|
||||
from multiprocessing.process import active_children as active_children, current_process as current_process
|
||||
|
||||
# These are technically functions that return instances of these Queue classes. See #4313 for discussion
|
||||
from multiprocessing.queues import JoinableQueue as JoinableQueue, Queue as Queue, SimpleQueue as SimpleQueue
|
||||
from multiprocessing.spawn import freeze_support as freeze_support
|
||||
from typing import Any, Callable, Iterable, List, Optional, Sequence, Tuple, Union, overload
|
||||
from typing_extensions import Literal
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
from multiprocessing.process import parent_process as parent_process
|
||||
|
||||
if sys.platform != "win32":
|
||||
from multiprocessing.context import ForkContext, ForkServerContext
|
||||
|
||||
# N.B. The functions below are generated at runtime by partially applying
|
||||
# multiprocessing.context.BaseContext's methods, so the two signatures should
|
||||
# be identical (modulo self).
|
||||
|
||||
# Sychronization primitives
|
||||
_LockLike = Union[synchronize.Lock, synchronize.RLock]
|
||||
|
||||
def Barrier(parties: int, action: Optional[Callable[..., Any]] = ..., timeout: Optional[float] = ...) -> synchronize.Barrier: ...
|
||||
def BoundedSemaphore(value: int = ...) -> synchronize.BoundedSemaphore: ...
|
||||
def Condition(lock: Optional[_LockLike] = ...) -> synchronize.Condition: ...
|
||||
def Event() -> synchronize.Event: ...
|
||||
def Lock() -> synchronize.Lock: ...
|
||||
def RLock() -> synchronize.RLock: ...
|
||||
def Semaphore(value: int = ...) -> synchronize.Semaphore: ...
|
||||
def Pipe(duplex: bool = ...) -> Tuple[connection.Connection, connection.Connection]: ...
|
||||
def Pool(
|
||||
processes: Optional[int] = ...,
|
||||
initializer: Optional[Callable[..., Any]] = ...,
|
||||
initargs: Iterable[Any] = ...,
|
||||
maxtasksperchild: Optional[int] = ...,
|
||||
) -> pool.Pool: ...
|
||||
|
||||
# Functions Array and Value are copied from context.pyi.
|
||||
# See https://github.com/python/typeshed/blob/ac234f25927634e06d9c96df98d72d54dd80dfc4/stdlib/2and3/turtle.pyi#L284-L291
|
||||
# for rationale
|
||||
def Array(typecode_or_type: Any, size_or_initializer: Union[int, Sequence[Any]], *, lock: bool = ...) -> sharedctypes._Array: ...
|
||||
def Value(typecode_or_type: Any, *args: Any, lock: bool = ...) -> sharedctypes._Value: ...
|
||||
|
||||
# ----- multiprocessing function stubs -----
|
||||
def allow_connection_pickling() -> None: ...
|
||||
def cpu_count() -> int: ...
|
||||
def get_logger() -> Logger: ...
|
||||
def log_to_stderr(level: Optional[Union[str, int]] = ...) -> Logger: ...
|
||||
def Manager() -> SyncManager: ...
|
||||
def set_executable(executable: str) -> None: ...
|
||||
def set_forkserver_preload(module_names: List[str]) -> None: ...
|
||||
def get_all_start_methods() -> List[str]: ...
|
||||
def get_start_method(allow_none: bool = ...) -> Optional[str]: ...
|
||||
def set_start_method(method: str, force: Optional[bool] = ...) -> None: ...
|
||||
|
||||
if sys.platform != "win32":
|
||||
@overload
|
||||
def get_context(method: None = ...) -> DefaultContext: ...
|
||||
@overload
|
||||
def get_context(method: Literal["spawn"]) -> SpawnContext: ...
|
||||
@overload
|
||||
def get_context(method: Literal["fork"]) -> ForkContext: ...
|
||||
@overload
|
||||
def get_context(method: Literal["forkserver"]) -> ForkServerContext: ...
|
||||
@overload
|
||||
def get_context(method: str) -> BaseContext: ...
|
||||
|
||||
else:
|
||||
@overload
|
||||
def get_context(method: None = ...) -> DefaultContext: ...
|
||||
@overload
|
||||
def get_context(method: Literal["spawn"]) -> SpawnContext: ...
|
||||
@overload
|
||||
def get_context(method: str) -> BaseContext: ...
|
||||
62
stdlib/multiprocessing/connection.pyi
Normal file
62
stdlib/multiprocessing/connection.pyi
Normal file
@@ -0,0 +1,62 @@
|
||||
import socket
|
||||
import sys
|
||||
import types
|
||||
from typing import Any, Iterable, List, Optional, Tuple, Type, Union
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
from typing import SupportsIndex
|
||||
|
||||
# https://docs.python.org/3/library/multiprocessing.html#address-formats
|
||||
_Address = Union[str, Tuple[str, int]]
|
||||
|
||||
class _ConnectionBase:
|
||||
if sys.version_info >= (3, 8):
|
||||
def __init__(self, handle: SupportsIndex, readable: bool = ..., writable: bool = ...) -> None: ...
|
||||
else:
|
||||
def __init__(self, handle: int, readable: bool = ..., writable: bool = ...) -> None: ...
|
||||
@property
|
||||
def closed(self) -> bool: ... # undocumented
|
||||
@property
|
||||
def readable(self) -> bool: ... # undocumented
|
||||
@property
|
||||
def writable(self) -> bool: ... # undocumented
|
||||
def fileno(self) -> int: ...
|
||||
def close(self) -> None: ...
|
||||
def send_bytes(self, buf: bytes, offset: int = ..., size: Optional[int] = ...) -> None: ...
|
||||
def send(self, obj: Any) -> None: ...
|
||||
def recv_bytes(self, maxlength: Optional[int] = ...) -> bytes: ...
|
||||
def recv_bytes_into(self, buf: Any, offset: int = ...) -> int: ...
|
||||
def recv(self) -> Any: ...
|
||||
def poll(self, timeout: Optional[float] = ...) -> bool: ...
|
||||
def __enter__(self) -> _ConnectionBase: ...
|
||||
def __exit__(
|
||||
self, exc_type: Optional[Type[BaseException]], exc_value: Optional[BaseException], exc_tb: Optional[types.TracebackType]
|
||||
) -> None: ...
|
||||
|
||||
class Connection(_ConnectionBase): ...
|
||||
|
||||
if sys.platform == "win32":
|
||||
class PipeConnection(_ConnectionBase): ...
|
||||
|
||||
class Listener:
|
||||
def __init__(
|
||||
self, address: Optional[_Address] = ..., family: Optional[str] = ..., backlog: int = ..., authkey: Optional[bytes] = ...
|
||||
) -> None: ...
|
||||
def accept(self) -> Connection: ...
|
||||
def close(self) -> None: ...
|
||||
@property
|
||||
def address(self) -> _Address: ...
|
||||
@property
|
||||
def last_accepted(self) -> Optional[_Address]: ...
|
||||
def __enter__(self) -> Listener: ...
|
||||
def __exit__(
|
||||
self, exc_type: Optional[Type[BaseException]], exc_value: Optional[BaseException], exc_tb: Optional[types.TracebackType]
|
||||
) -> None: ...
|
||||
|
||||
def deliver_challenge(connection: Connection, authkey: bytes) -> None: ...
|
||||
def answer_challenge(connection: Connection, authkey: bytes) -> None: ...
|
||||
def wait(
|
||||
object_list: Iterable[Union[Connection, socket.socket, int]], timeout: Optional[float] = ...
|
||||
) -> List[Union[Connection, socket.socket, int]]: ...
|
||||
def Client(address: _Address, family: Optional[str] = ..., authkey: Optional[bytes] = ...) -> Connection: ...
|
||||
def Pipe(duplex: bool = ...) -> Tuple[Connection, Connection]: ...
|
||||
151
stdlib/multiprocessing/context.pyi
Normal file
151
stdlib/multiprocessing/context.pyi
Normal file
@@ -0,0 +1,151 @@
|
||||
import multiprocessing
|
||||
import sys
|
||||
from logging import Logger
|
||||
from multiprocessing import queues, sharedctypes, synchronize
|
||||
from multiprocessing.process import BaseProcess
|
||||
from typing import Any, Callable, Iterable, List, Optional, Sequence, Type, Union, overload
|
||||
from typing_extensions import Literal
|
||||
|
||||
_LockLike = Union[synchronize.Lock, synchronize.RLock]
|
||||
|
||||
class ProcessError(Exception): ...
|
||||
class BufferTooShort(ProcessError): ...
|
||||
class TimeoutError(ProcessError): ...
|
||||
class AuthenticationError(ProcessError): ...
|
||||
|
||||
class BaseContext(object):
|
||||
Process: Type[BaseProcess]
|
||||
ProcessError: Type[Exception]
|
||||
BufferTooShort: Type[Exception]
|
||||
TimeoutError: Type[Exception]
|
||||
AuthenticationError: Type[Exception]
|
||||
|
||||
# N.B. The methods below are applied at runtime to generate
|
||||
# multiprocessing.*, so the signatures should be identical (modulo self).
|
||||
@staticmethod
|
||||
def current_process() -> BaseProcess: ...
|
||||
if sys.version_info >= (3, 8):
|
||||
@staticmethod
|
||||
def parent_process() -> Optional[BaseProcess]: ...
|
||||
@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 Barrier(
|
||||
self, parties: int, action: Optional[Callable[..., Any]] = ..., timeout: Optional[float] = ...
|
||||
) -> synchronize.Barrier: ...
|
||||
def BoundedSemaphore(self, value: int = ...) -> synchronize.BoundedSemaphore: ...
|
||||
def Condition(self, lock: Optional[_LockLike] = ...) -> synchronize.Condition: ...
|
||||
def Event(self) -> synchronize.Event: ...
|
||||
def Lock(self) -> synchronize.Lock: ...
|
||||
def RLock(self) -> synchronize.RLock: ...
|
||||
def Semaphore(self, value: int = ...) -> synchronize.Semaphore: ...
|
||||
def Queue(self, maxsize: int = ...) -> queues.Queue[Any]: ...
|
||||
def JoinableQueue(self, maxsize: int = ...) -> queues.JoinableQueue[Any]: ...
|
||||
def SimpleQueue(self) -> queues.SimpleQueue[Any]: ...
|
||||
def Pool(
|
||||
self,
|
||||
processes: Optional[int] = ...,
|
||||
initializer: Optional[Callable[..., Any]] = ...,
|
||||
initargs: Iterable[Any] = ...,
|
||||
maxtasksperchild: Optional[int] = ...,
|
||||
) -> multiprocessing.pool.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
|
||||
def RawValue(self, typecode_or_type: Any, *args: Any) -> Any: ...
|
||||
# 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 RawArray once a stub exists in multiprocessing.sharedctypes
|
||||
def RawArray(self, typecode_or_type: Any, size_or_initializer: Union[int, Sequence[Any]]) -> Any: ...
|
||||
# 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
|
||||
def Value(self, typecode_or_type: Any, *args: Any, lock: bool = ...) -> sharedctypes._Value: ...
|
||||
# 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
|
||||
def Array(
|
||||
self, typecode_or_type: Any, size_or_initializer: Union[int, Sequence[Any]], *, lock: bool = ...
|
||||
) -> sharedctypes._Array: ...
|
||||
def freeze_support(self) -> None: ...
|
||||
def get_logger(self) -> Logger: ...
|
||||
def log_to_stderr(self, level: Optional[str] = ...) -> Logger: ...
|
||||
def allow_connection_pickling(self) -> None: ...
|
||||
def set_executable(self, executable: str) -> None: ...
|
||||
def set_forkserver_preload(self, module_names: List[str]) -> None: ...
|
||||
if sys.platform != "win32":
|
||||
@overload
|
||||
def get_context(self, method: None = ...) -> DefaultContext: ...
|
||||
@overload
|
||||
def get_context(self, method: Literal["spawn"]) -> SpawnContext: ...
|
||||
@overload
|
||||
def get_context(self, method: Literal["fork"]) -> ForkContext: ...
|
||||
@overload
|
||||
def get_context(self, method: Literal["forkserver"]) -> ForkServerContext: ...
|
||||
@overload
|
||||
def get_context(self, method: str) -> BaseContext: ...
|
||||
else:
|
||||
@overload
|
||||
def get_context(self, method: None = ...) -> DefaultContext: ...
|
||||
@overload
|
||||
def get_context(self, method: Literal["spawn"]) -> SpawnContext: ...
|
||||
@overload
|
||||
def get_context(self, method: str) -> BaseContext: ...
|
||||
def get_start_method(self, allow_none: bool = ...) -> str: ...
|
||||
def set_start_method(self, method: Optional[str], force: bool = ...) -> None: ...
|
||||
@property
|
||||
def reducer(self) -> str: ...
|
||||
@reducer.setter
|
||||
def reducer(self, reduction: str) -> None: ...
|
||||
def _check_available(self) -> None: ...
|
||||
|
||||
class Process(BaseProcess):
|
||||
_start_method: Optional[str]
|
||||
@staticmethod
|
||||
def _Popen(process_obj: BaseProcess) -> DefaultContext: ...
|
||||
|
||||
class DefaultContext(BaseContext):
|
||||
Process: Type[multiprocessing.Process]
|
||||
def __init__(self, context: BaseContext) -> None: ...
|
||||
def set_start_method(self, method: Optional[str], force: bool = ...) -> None: ...
|
||||
def get_start_method(self, allow_none: bool = ...) -> str: ...
|
||||
def get_all_start_methods(self) -> List[str]: ...
|
||||
|
||||
if sys.platform != "win32":
|
||||
class ForkProcess(BaseProcess):
|
||||
_start_method: str
|
||||
@staticmethod
|
||||
def _Popen(process_obj: BaseProcess) -> Any: ...
|
||||
class SpawnProcess(BaseProcess):
|
||||
_start_method: str
|
||||
@staticmethod
|
||||
def _Popen(process_obj: BaseProcess) -> SpawnProcess: ...
|
||||
class ForkServerProcess(BaseProcess):
|
||||
_start_method: str
|
||||
@staticmethod
|
||||
def _Popen(process_obj: BaseProcess) -> Any: ...
|
||||
class ForkContext(BaseContext):
|
||||
_name: str
|
||||
Process: Type[ForkProcess]
|
||||
class SpawnContext(BaseContext):
|
||||
_name: str
|
||||
Process: Type[SpawnProcess]
|
||||
class ForkServerContext(BaseContext):
|
||||
_name: str
|
||||
Process: Type[ForkServerProcess]
|
||||
|
||||
else:
|
||||
class SpawnProcess(BaseProcess):
|
||||
_start_method: str
|
||||
@staticmethod
|
||||
def _Popen(process_obj: BaseProcess) -> Any: ...
|
||||
class SpawnContext(BaseContext):
|
||||
_name: str
|
||||
Process: Type[SpawnProcess]
|
||||
|
||||
def _force_start_method(method: str) -> None: ...
|
||||
def get_spawning_popen() -> Optional[Any]: ...
|
||||
def set_spawning_popen(popen: Any) -> None: ...
|
||||
def assert_spawning(obj: Any) -> None: ...
|
||||
52
stdlib/multiprocessing/dummy/__init__.pyi
Normal file
52
stdlib/multiprocessing/dummy/__init__.pyi
Normal file
@@ -0,0 +1,52 @@
|
||||
import array
|
||||
import threading
|
||||
import weakref
|
||||
from queue import Queue as Queue
|
||||
from typing import Any, Callable, Iterable, List, Mapping, Optional, Sequence
|
||||
|
||||
JoinableQueue = Queue
|
||||
Barrier = threading.Barrier
|
||||
BoundedSemaphore = threading.BoundedSemaphore
|
||||
Condition = threading.Condition
|
||||
Event = threading.Event
|
||||
Lock = threading.Lock
|
||||
RLock = threading.RLock
|
||||
Semaphore = threading.Semaphore
|
||||
|
||||
class DummyProcess(threading.Thread):
|
||||
_children: weakref.WeakKeyDictionary[Any, Any]
|
||||
_parent: threading.Thread
|
||||
_pid: None
|
||||
_start_called: int
|
||||
exitcode: Optional[int]
|
||||
def __init__(
|
||||
self,
|
||||
group: Any = ...,
|
||||
target: Optional[Callable[..., Any]] = ...,
|
||||
name: Optional[str] = ...,
|
||||
args: Iterable[Any] = ...,
|
||||
kwargs: Mapping[str, Any] = ...,
|
||||
) -> None: ...
|
||||
|
||||
Process = DummyProcess
|
||||
|
||||
class Namespace:
|
||||
def __init__(self, **kwds: Any) -> None: ...
|
||||
def __getattr__(self, __name: str) -> Any: ...
|
||||
def __setattr__(self, __name: str, __value: Any) -> None: ...
|
||||
|
||||
class Value:
|
||||
_typecode: Any
|
||||
_value: Any
|
||||
value: Any
|
||||
def __init__(self, typecode: Any, value: Any, lock: Any = ...) -> None: ...
|
||||
|
||||
def Array(typecode: Any, sequence: Sequence[Any], lock: Any = ...) -> array.array[Any]: ...
|
||||
def Manager() -> Any: ...
|
||||
def Pool(
|
||||
processes: Optional[int] = ..., initializer: Optional[Callable[..., Any]] = ..., initargs: Iterable[Any] = ...
|
||||
) -> Any: ...
|
||||
def active_children() -> List[Any]: ...
|
||||
def current_process() -> threading.Thread: ...
|
||||
def freeze_support() -> None: ...
|
||||
def shutdown() -> None: ...
|
||||
39
stdlib/multiprocessing/dummy/connection.pyi
Normal file
39
stdlib/multiprocessing/dummy/connection.pyi
Normal file
@@ -0,0 +1,39 @@
|
||||
from queue import Queue
|
||||
from types import TracebackType
|
||||
from typing import Any, List, Optional, Tuple, Type, TypeVar, Union
|
||||
|
||||
families: List[None]
|
||||
|
||||
_ConnectionT = TypeVar("_ConnectionT", bound=Connection)
|
||||
_ListenerT = TypeVar("_ListenerT", bound=Listener)
|
||||
_Address = Union[str, Tuple[str, int]]
|
||||
|
||||
class Connection(object):
|
||||
_in: Any
|
||||
_out: Any
|
||||
recv: Any
|
||||
recv_bytes: Any
|
||||
send: Any
|
||||
send_bytes: Any
|
||||
def __enter__(self: _ConnectionT) -> _ConnectionT: ...
|
||||
def __exit__(
|
||||
self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]
|
||||
) -> None: ...
|
||||
def __init__(self, _in: Any, _out: Any) -> None: ...
|
||||
def close(self) -> None: ...
|
||||
def poll(self, timeout: float = ...) -> bool: ...
|
||||
|
||||
class Listener(object):
|
||||
_backlog_queue: Optional[Queue[Any]]
|
||||
@property
|
||||
def address(self) -> Optional[Queue[Any]]: ...
|
||||
def __enter__(self: _ListenerT) -> _ListenerT: ...
|
||||
def __exit__(
|
||||
self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]
|
||||
) -> None: ...
|
||||
def __init__(self, address: Optional[_Address] = ..., family: Optional[int] = ..., backlog: int = ...) -> None: ...
|
||||
def accept(self) -> Connection: ...
|
||||
def close(self) -> None: ...
|
||||
|
||||
def Client(address: _Address) -> Connection: ...
|
||||
def Pipe(duplex: bool = ...) -> Tuple[Connection, Connection]: ...
|
||||
142
stdlib/multiprocessing/managers.pyi
Normal file
142
stdlib/multiprocessing/managers.pyi
Normal file
@@ -0,0 +1,142 @@
|
||||
# NOTE: These are incomplete!
|
||||
|
||||
import queue
|
||||
import sys
|
||||
import threading
|
||||
from typing import (
|
||||
Any,
|
||||
AnyStr,
|
||||
Callable,
|
||||
ContextManager,
|
||||
Dict,
|
||||
Generic,
|
||||
Iterable,
|
||||
List,
|
||||
Mapping,
|
||||
Optional,
|
||||
Sequence,
|
||||
Tuple,
|
||||
TypeVar,
|
||||
Union,
|
||||
)
|
||||
|
||||
from .connection import Connection
|
||||
from .context import BaseContext
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
from .shared_memory import _SLT, ShareableList, SharedMemory
|
||||
|
||||
_SharedMemory = SharedMemory
|
||||
_ShareableList = ShareableList
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
from types import GenericAlias
|
||||
|
||||
_T = TypeVar("_T")
|
||||
_KT = TypeVar("_KT")
|
||||
_VT = TypeVar("_VT")
|
||||
|
||||
class Namespace:
|
||||
def __init__(self, **kwds: Any) -> None: ...
|
||||
def __getattr__(self, __name: str) -> Any: ...
|
||||
def __setattr__(self, __name: str, __value: Any) -> None: ...
|
||||
|
||||
_Namespace = Namespace
|
||||
|
||||
class Token(object):
|
||||
typeid: Optional[Union[str, bytes]]
|
||||
address: Tuple[Union[str, bytes], int]
|
||||
id: Optional[Union[str, bytes, int]]
|
||||
def __init__(
|
||||
self, typeid: Optional[Union[bytes, str]], address: Tuple[Union[str, bytes], int], id: Optional[Union[str, bytes, int]]
|
||||
) -> None: ...
|
||||
def __repr__(self) -> str: ...
|
||||
def __getstate__(
|
||||
self,
|
||||
) -> Tuple[Optional[Union[str, bytes]], Tuple[Union[str, bytes], int], Optional[Union[str, bytes, int]]]: ...
|
||||
def __setstate__(
|
||||
self, state: Tuple[Optional[Union[str, bytes]], Tuple[Union[str, bytes], int], Optional[Union[str, bytes, int]]]
|
||||
) -> None: ...
|
||||
|
||||
class BaseProxy(object):
|
||||
_address_to_local: Dict[Any, Any]
|
||||
_mutex: Any
|
||||
def __init__(
|
||||
self,
|
||||
token: Any,
|
||||
serializer: str,
|
||||
manager: Any = ...,
|
||||
authkey: Optional[AnyStr] = ...,
|
||||
exposed: Any = ...,
|
||||
incref: bool = ...,
|
||||
manager_owned: bool = ...,
|
||||
) -> None: ...
|
||||
def __deepcopy__(self, memo: Optional[Any]) -> Any: ...
|
||||
def _callmethod(self, methodname: str, args: Tuple[Any, ...] = ..., kwds: Dict[Any, Any] = ...) -> None: ...
|
||||
def _getvalue(self) -> Any: ...
|
||||
def __reduce__(self) -> Tuple[Any, Tuple[Any, Any, str, Dict[Any, Any]]]: ...
|
||||
|
||||
class ValueProxy(BaseProxy, Generic[_T]):
|
||||
def get(self) -> _T: ...
|
||||
def set(self, value: _T) -> None: ...
|
||||
value: _T
|
||||
if sys.version_info >= (3, 9):
|
||||
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
|
||||
|
||||
# Returned by BaseManager.get_server()
|
||||
class Server:
|
||||
address: Any
|
||||
def __init__(
|
||||
self, registry: Dict[str, Tuple[Callable[..., Any], Any, Any, Any]], address: Any, authkey: bytes, serializer: str
|
||||
) -> None: ...
|
||||
def serve_forever(self) -> None: ...
|
||||
def accept_connection(self, c: Connection, name: str) -> None: ...
|
||||
|
||||
class BaseManager(ContextManager[BaseManager]):
|
||||
def __init__(
|
||||
self,
|
||||
address: Optional[Any] = ...,
|
||||
authkey: Optional[bytes] = ...,
|
||||
serializer: str = ...,
|
||||
ctx: Optional[BaseContext] = ...,
|
||||
) -> None: ...
|
||||
def get_server(self) -> Server: ...
|
||||
def connect(self) -> None: ...
|
||||
def start(self, initializer: Optional[Callable[..., Any]] = ..., initargs: Iterable[Any] = ...) -> None: ...
|
||||
def shutdown(self) -> None: ... # only available after start() was called
|
||||
def join(self, timeout: Optional[float] = ...) -> None: ... # undocumented
|
||||
@property
|
||||
def address(self) -> Any: ...
|
||||
@classmethod
|
||||
def register(
|
||||
cls,
|
||||
typeid: str,
|
||||
callable: Optional[Callable[..., Any]] = ...,
|
||||
proxytype: Any = ...,
|
||||
exposed: Optional[Sequence[str]] = ...,
|
||||
method_to_typeid: Optional[Mapping[str, str]] = ...,
|
||||
create_method: bool = ...,
|
||||
) -> None: ...
|
||||
|
||||
class SyncManager(BaseManager, ContextManager[SyncManager]):
|
||||
def BoundedSemaphore(self, value: Any = ...) -> threading.BoundedSemaphore: ...
|
||||
def Condition(self, lock: Any = ...) -> threading.Condition: ...
|
||||
def Event(self) -> threading.Event: ...
|
||||
def Lock(self) -> threading.Lock: ...
|
||||
def Namespace(self) -> _Namespace: ...
|
||||
def Queue(self, maxsize: int = ...) -> queue.Queue[Any]: ...
|
||||
def RLock(self) -> threading.RLock: ...
|
||||
def Semaphore(self, value: Any = ...) -> threading.Semaphore: ...
|
||||
def Array(self, typecode: Any, sequence: Sequence[_T]) -> Sequence[_T]: ...
|
||||
def Value(self, typecode: Any, value: _T) -> ValueProxy[_T]: ...
|
||||
def dict(self, sequence: Mapping[_KT, _VT] = ...) -> Dict[_KT, _VT]: ...
|
||||
def list(self, sequence: Sequence[_T] = ...) -> List[_T]: ...
|
||||
|
||||
class RemoteError(Exception): ...
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
class SharedMemoryServer(Server): ...
|
||||
class SharedMemoryManager(BaseManager):
|
||||
def get_server(self) -> SharedMemoryServer: ...
|
||||
def SharedMemory(self, size: int) -> _SharedMemory: ...
|
||||
def ShareableList(self, sequence: Optional[Iterable[_SLT]]) -> _ShareableList[_SLT]: ...
|
||||
90
stdlib/multiprocessing/pool.pyi
Normal file
90
stdlib/multiprocessing/pool.pyi
Normal file
@@ -0,0 +1,90 @@
|
||||
import sys
|
||||
from typing import Any, Callable, ContextManager, Generic, Iterable, Iterator, List, Mapping, Optional, TypeVar
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
from types import GenericAlias
|
||||
|
||||
_PT = TypeVar("_PT", bound=Pool)
|
||||
_S = TypeVar("_S")
|
||||
_T = TypeVar("_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: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
|
||||
|
||||
# alias created during issue #17805
|
||||
AsyncResult = ApplyResult
|
||||
|
||||
class MapResult(ApplyResult[List[_T]]): ...
|
||||
|
||||
class IMapIterator(Iterator[_T]):
|
||||
def __iter__(self: _S) -> _S: ...
|
||||
def next(self, timeout: Optional[float] = ...) -> _T: ...
|
||||
def __next__(self, timeout: Optional[float] = ...) -> _T: ...
|
||||
|
||||
class IMapUnorderedIterator(IMapIterator[_T]): ...
|
||||
|
||||
class Pool(ContextManager[Pool]):
|
||||
def __init__(
|
||||
self,
|
||||
processes: Optional[int] = ...,
|
||||
initializer: Optional[Callable[..., None]] = ...,
|
||||
initargs: Iterable[Any] = ...,
|
||||
maxtasksperchild: Optional[int] = ...,
|
||||
context: Optional[Any] = ...,
|
||||
) -> None: ...
|
||||
def apply(self, func: Callable[..., _T], args: Iterable[Any] = ..., kwds: Mapping[str, Any] = ...) -> _T: ...
|
||||
def apply_async(
|
||||
self,
|
||||
func: Callable[..., _T],
|
||||
args: Iterable[Any] = ...,
|
||||
kwds: Mapping[str, Any] = ...,
|
||||
callback: Optional[Callable[[_T], None]] = ...,
|
||||
error_callback: Optional[Callable[[BaseException], None]] = ...,
|
||||
) -> AsyncResult[_T]: ...
|
||||
def map(self, func: Callable[[_S], _T], iterable: Iterable[_S], chunksize: Optional[int] = ...) -> List[_T]: ...
|
||||
def map_async(
|
||||
self,
|
||||
func: Callable[[_S], _T],
|
||||
iterable: Iterable[_S],
|
||||
chunksize: Optional[int] = ...,
|
||||
callback: Optional[Callable[[_T], None]] = ...,
|
||||
error_callback: Optional[Callable[[BaseException], None]] = ...,
|
||||
) -> MapResult[_T]: ...
|
||||
def imap(self, func: Callable[[_S], _T], iterable: Iterable[_S], chunksize: Optional[int] = ...) -> IMapIterator[_T]: ...
|
||||
def imap_unordered(
|
||||
self, func: Callable[[_S], _T], iterable: Iterable[_S], chunksize: Optional[int] = ...
|
||||
) -> IMapIterator[_T]: ...
|
||||
def starmap(self, func: Callable[..., _T], iterable: Iterable[Iterable[Any]], chunksize: Optional[int] = ...) -> List[_T]: ...
|
||||
def starmap_async(
|
||||
self,
|
||||
func: Callable[..., _T],
|
||||
iterable: Iterable[Iterable[Any]],
|
||||
chunksize: Optional[int] = ...,
|
||||
callback: Optional[Callable[[_T], None]] = ...,
|
||||
error_callback: Optional[Callable[[BaseException], None]] = ...,
|
||||
) -> AsyncResult[List[_T]]: ...
|
||||
def close(self) -> None: ...
|
||||
def terminate(self) -> None: ...
|
||||
def join(self) -> None: ...
|
||||
def __enter__(self: _PT) -> _PT: ...
|
||||
|
||||
class ThreadPool(Pool, ContextManager[ThreadPool]):
|
||||
def __init__(
|
||||
self, processes: Optional[int] = ..., initializer: Optional[Callable[..., Any]] = ..., initargs: Iterable[Any] = ...
|
||||
) -> None: ...
|
||||
|
||||
# undocumented
|
||||
if sys.version_info >= (3, 8):
|
||||
INIT: str
|
||||
RUN: str
|
||||
CLOSE: str
|
||||
TERMINATE: str
|
||||
else:
|
||||
RUN: int
|
||||
CLOSE: int
|
||||
TERMINATE: int
|
||||
39
stdlib/multiprocessing/process.pyi
Normal file
39
stdlib/multiprocessing/process.pyi
Normal file
@@ -0,0 +1,39 @@
|
||||
import sys
|
||||
from typing import Any, Callable, List, Mapping, Optional, Tuple
|
||||
|
||||
class BaseProcess:
|
||||
name: str
|
||||
daemon: bool
|
||||
authkey: bytes
|
||||
def __init__(
|
||||
self,
|
||||
group: None = ...,
|
||||
target: Optional[Callable[..., Any]] = ...,
|
||||
name: Optional[str] = ...,
|
||||
args: Tuple[Any, ...] = ...,
|
||||
kwargs: Mapping[str, Any] = ...,
|
||||
*,
|
||||
daemon: Optional[bool] = ...,
|
||||
) -> None: ...
|
||||
def run(self) -> None: ...
|
||||
def start(self) -> None: ...
|
||||
def terminate(self) -> None: ...
|
||||
if sys.version_info >= (3, 7):
|
||||
def kill(self) -> None: ...
|
||||
def close(self) -> None: ...
|
||||
def join(self, timeout: Optional[float] = ...) -> None: ...
|
||||
def is_alive(self) -> bool: ...
|
||||
@property
|
||||
def exitcode(self) -> Optional[int]: ...
|
||||
@property
|
||||
def ident(self) -> Optional[int]: ...
|
||||
@property
|
||||
def pid(self) -> Optional[int]: ...
|
||||
@property
|
||||
def sentinel(self) -> int: ...
|
||||
|
||||
def current_process() -> BaseProcess: ...
|
||||
def active_children() -> List[BaseProcess]: ...
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
def parent_process() -> Optional[BaseProcess]: ...
|
||||
35
stdlib/multiprocessing/queues.pyi
Normal file
35
stdlib/multiprocessing/queues.pyi
Normal file
@@ -0,0 +1,35 @@
|
||||
import queue
|
||||
import sys
|
||||
from typing import Any, Generic, Optional, TypeVar
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
from types import GenericAlias
|
||||
|
||||
_T = TypeVar("_T")
|
||||
|
||||
class Queue(queue.Queue[_T]):
|
||||
# FIXME: `ctx` is a circular dependency and it's not actually optional.
|
||||
# It's marked as such to be able to use the generic Queue in __init__.pyi.
|
||||
def __init__(self, maxsize: int = ..., *, ctx: Any = ...) -> None: ...
|
||||
def get(self, block: bool = ..., timeout: Optional[float] = ...) -> _T: ...
|
||||
def put(self, obj: _T, block: bool = ..., timeout: Optional[float] = ...) -> None: ...
|
||||
def qsize(self) -> int: ...
|
||||
def empty(self) -> bool: ...
|
||||
def full(self) -> bool: ...
|
||||
def put_nowait(self, item: _T) -> None: ...
|
||||
def get_nowait(self) -> _T: ...
|
||||
def close(self) -> None: ...
|
||||
def join_thread(self) -> None: ...
|
||||
def cancel_join_thread(self) -> None: ...
|
||||
|
||||
class JoinableQueue(Queue[_T]):
|
||||
def task_done(self) -> None: ...
|
||||
def join(self) -> None: ...
|
||||
|
||||
class SimpleQueue(Generic[_T]):
|
||||
def __init__(self, *, ctx: Any = ...) -> None: ...
|
||||
def empty(self) -> bool: ...
|
||||
def get(self) -> _T: ...
|
||||
def put(self, item: _T) -> None: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
|
||||
33
stdlib/multiprocessing/shared_memory.pyi
Normal file
33
stdlib/multiprocessing/shared_memory.pyi
Normal file
@@ -0,0 +1,33 @@
|
||||
import sys
|
||||
from typing import Any, Generic, Iterable, Optional, Tuple, TypeVar
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
from types import GenericAlias
|
||||
|
||||
_S = TypeVar("_S")
|
||||
_SLT = TypeVar("_SLT", int, float, bool, str, bytes, None)
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
class SharedMemory:
|
||||
def __init__(self, name: Optional[str] = ..., create: bool = ..., size: int = ...) -> None: ...
|
||||
@property
|
||||
def buf(self) -> memoryview: ...
|
||||
@property
|
||||
def name(self) -> str: ...
|
||||
@property
|
||||
def size(self) -> int: ...
|
||||
def close(self) -> None: ...
|
||||
def unlink(self) -> None: ...
|
||||
class ShareableList(Generic[_SLT]):
|
||||
shm: SharedMemory
|
||||
def __init__(self, sequence: Optional[Iterable[_SLT]] = ..., *, name: Optional[str] = ...) -> None: ...
|
||||
def __getitem__(self, position: int) -> _SLT: ...
|
||||
def __setitem__(self, position: int, value: _SLT) -> None: ...
|
||||
def __reduce__(self: _S) -> Tuple[_S, Tuple[_SLT, ...]]: ...
|
||||
def __len__(self) -> int: ...
|
||||
@property
|
||||
def format(self) -> str: ...
|
||||
def count(self, value: _SLT) -> int: ...
|
||||
def index(self, value: _SLT) -> int: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
|
||||
43
stdlib/multiprocessing/sharedctypes.pyi
Normal file
43
stdlib/multiprocessing/sharedctypes.pyi
Normal file
@@ -0,0 +1,43 @@
|
||||
from ctypes import _CData
|
||||
from multiprocessing.context import BaseContext
|
||||
from multiprocessing.synchronize import _LockLike
|
||||
from typing import Any, List, Optional, Sequence, Type, Union, overload
|
||||
|
||||
class _Array:
|
||||
value: Any = ...
|
||||
def __init__(
|
||||
self,
|
||||
typecode_or_type: Union[str, Type[_CData]],
|
||||
size_or_initializer: Union[int, Sequence[Any]],
|
||||
*,
|
||||
lock: Union[bool, _LockLike] = ...,
|
||||
) -> None: ...
|
||||
def acquire(self) -> bool: ...
|
||||
def release(self) -> bool: ...
|
||||
def get_lock(self) -> _LockLike: ...
|
||||
def get_obj(self) -> Any: ...
|
||||
@overload
|
||||
def __getitem__(self, key: int) -> Any: ...
|
||||
@overload
|
||||
def __getitem__(self, key: slice) -> List[Any]: ...
|
||||
def __getslice__(self, start: int, stop: int) -> Any: ...
|
||||
def __setitem__(self, key: int, value: Any) -> None: ...
|
||||
|
||||
class _Value:
|
||||
value: Any = ...
|
||||
def __init__(self, typecode_or_type: Union[str, Type[_CData]], *args: Any, lock: Union[bool, _LockLike] = ...) -> None: ...
|
||||
def get_lock(self) -> _LockLike: ...
|
||||
def get_obj(self) -> Any: ...
|
||||
def acquire(self) -> bool: ...
|
||||
def release(self) -> bool: ...
|
||||
|
||||
def Array(
|
||||
typecode_or_type: Union[str, Type[_CData]],
|
||||
size_or_initializer: Union[int, Sequence[Any]],
|
||||
*,
|
||||
lock: Union[bool, _LockLike] = ...,
|
||||
ctx: Optional[BaseContext] = ...,
|
||||
) -> _Array: ...
|
||||
def Value(
|
||||
typecode_or_type: Union[str, Type[_CData]], *args: Any, lock: Union[bool, _LockLike] = ..., ctx: Optional[BaseContext] = ...
|
||||
) -> _Value: ...
|
||||
21
stdlib/multiprocessing/spawn.pyi
Normal file
21
stdlib/multiprocessing/spawn.pyi
Normal file
@@ -0,0 +1,21 @@
|
||||
from types import ModuleType
|
||||
from typing import Any, Dict, List, Mapping, Optional, Sequence
|
||||
|
||||
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: ...
|
||||
47
stdlib/multiprocessing/synchronize.pyi
Normal file
47
stdlib/multiprocessing/synchronize.pyi
Normal file
@@ -0,0 +1,47 @@
|
||||
import sys
|
||||
import threading
|
||||
from multiprocessing.context import BaseContext
|
||||
from typing import Any, Callable, ContextManager, Optional, Union
|
||||
|
||||
_LockLike = Union[Lock, RLock]
|
||||
|
||||
class Barrier(threading.Barrier):
|
||||
def __init__(
|
||||
self, parties: int, action: Optional[Callable[..., Any]] = ..., timeout: Optional[float] = ..., *ctx: BaseContext
|
||||
) -> None: ...
|
||||
|
||||
class BoundedSemaphore(Semaphore):
|
||||
def __init__(self, value: int = ..., *, ctx: BaseContext) -> None: ...
|
||||
|
||||
class Condition(ContextManager[bool]):
|
||||
def __init__(self, lock: Optional[_LockLike] = ..., *, ctx: BaseContext) -> None: ...
|
||||
if sys.version_info >= (3, 7):
|
||||
def notify(self, n: int = ...) -> None: ...
|
||||
else:
|
||||
def notify(self) -> None: ...
|
||||
def notify_all(self) -> None: ...
|
||||
def wait(self, timeout: Optional[float] = ...) -> bool: ...
|
||||
def wait_for(self, predicate: Callable[[], bool], timeout: Optional[float] = ...) -> bool: ...
|
||||
def acquire(self, block: bool = ..., timeout: Optional[float] = ...) -> bool: ...
|
||||
def release(self) -> None: ...
|
||||
|
||||
class Event(ContextManager[bool]):
|
||||
def __init__(self, lock: Optional[_LockLike] = ..., *, ctx: BaseContext) -> None: ...
|
||||
def is_set(self) -> bool: ...
|
||||
def set(self) -> None: ...
|
||||
def clear(self) -> None: ...
|
||||
def wait(self, timeout: Optional[float] = ...) -> bool: ...
|
||||
|
||||
class Lock(SemLock):
|
||||
def __init__(self, *, ctx: BaseContext) -> None: ...
|
||||
|
||||
class RLock(SemLock):
|
||||
def __init__(self, *, ctx: BaseContext) -> None: ...
|
||||
|
||||
class Semaphore(SemLock):
|
||||
def __init__(self, value: int = ..., *, ctx: BaseContext) -> None: ...
|
||||
|
||||
# Not part of public API
|
||||
class SemLock(ContextManager[bool]):
|
||||
def acquire(self, block: bool = ..., timeout: Optional[float] = ...) -> bool: ...
|
||||
def release(self) -> None: ...
|
||||
Reference in New Issue
Block a user