massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-pyright / node_modules / pyright / dist / typeshed-fallback / stdlib / multiprocessing / __init__.pyi
1 import sys
2 from collections.abc import Callable, Iterable
3 from logging import Logger
4 from multiprocessing import connection, context, pool, synchronize
5 from multiprocessing.context import (
6     AuthenticationError as AuthenticationError,
7     BaseContext,
8     BufferTooShort as BufferTooShort,
9     DefaultContext,
10     Process as Process,
11     ProcessError as ProcessError,
12     SpawnContext,
13     TimeoutError as TimeoutError,
14 )
15 from multiprocessing.managers import SyncManager
16 from multiprocessing.process import active_children as active_children, current_process as current_process
17
18 # These are technically functions that return instances of these Queue classes.
19 # Using them as annotations is deprecated. Either use imports from
20 # multiprocessing.queues or the aliases defined below. See #4266 for discussion.
21 from multiprocessing.queues import JoinableQueue as JoinableQueue, Queue as Queue, SimpleQueue as SimpleQueue
22 from multiprocessing.spawn import freeze_support as freeze_support
23 from typing import Any, Union, overload
24 from typing_extensions import Literal
25
26 if sys.version_info >= (3, 8):
27     from multiprocessing.process import parent_process as parent_process
28
29 if sys.platform != "win32":
30     from multiprocessing.context import ForkContext, ForkServerContext
31
32 # The following type aliases can be used to annotate the return values of
33 # the corresponding functions. They are not defined at runtime.
34 #
35 # from multiprocessing import Lock
36 # from typing import TYPE_CHECKING
37 # if TYPE_CHECKING:
38 #     from multiprocessing import _LockType
39 # lock: _LockType = Lock()
40
41 _QueueType = Queue
42 _SimpleQueueType = SimpleQueue
43 _JoinableQueueType = JoinableQueue
44 _BarrierType = synchronize.Barrier
45 _BoundedSemaphoreType = synchronize.BoundedSemaphore
46 _ConditionType = synchronize.Condition
47 _EventType = synchronize.Event
48 _LockType = synchronize.Lock
49 _RLockType = synchronize.RLock
50 _SemaphoreType = synchronize.Semaphore
51
52 # N.B. The functions below are generated at runtime by partially applying
53 # multiprocessing.context.BaseContext's methods, so the two signatures should
54 # be identical (modulo self).
55
56 # Synchronization primitives
57 _LockLike = Union[synchronize.Lock, synchronize.RLock]
58 RawValue = context._default_context.RawValue
59 RawArray = context._default_context.RawArray
60 Value = context._default_context.Value
61 Array = context._default_context.Array
62
63 def Barrier(parties: int, action: Callable[..., Any] | None = ..., timeout: float | None = ...) -> _BarrierType: ...
64 def BoundedSemaphore(value: int = ...) -> _BoundedSemaphoreType: ...
65 def Condition(lock: _LockLike | None = ...) -> _ConditionType: ...
66 def Event() -> _EventType: ...
67 def Lock() -> _LockType: ...
68 def RLock() -> _RLockType: ...
69 def Semaphore(value: int = ...) -> _SemaphoreType: ...
70 def Pipe(duplex: bool = ...) -> tuple[connection.Connection, connection.Connection]: ...
71 def Pool(
72     processes: int | None = ...,
73     initializer: Callable[..., Any] | None = ...,
74     initargs: Iterable[Any] = ...,
75     maxtasksperchild: int | None = ...,
76 ) -> pool.Pool: ...
77
78 # ----- multiprocessing function stubs -----
79 def allow_connection_pickling() -> None: ...
80 def cpu_count() -> int: ...
81 def get_logger() -> Logger: ...
82 def log_to_stderr(level: str | int | None = ...) -> Logger: ...
83 def Manager() -> SyncManager: ...
84 def set_executable(executable: str) -> None: ...
85 def set_forkserver_preload(module_names: list[str]) -> None: ...
86 def get_all_start_methods() -> list[str]: ...
87 def get_start_method(allow_none: bool = ...) -> str | None: ...
88 def set_start_method(method: str, force: bool | None = ...) -> None: ...
89
90 if sys.platform != "win32":
91     @overload
92     def get_context(method: None = ...) -> DefaultContext: ...
93     @overload
94     def get_context(method: Literal["spawn"]) -> SpawnContext: ...
95     @overload
96     def get_context(method: Literal["fork"]) -> ForkContext: ...
97     @overload
98     def get_context(method: Literal["forkserver"]) -> ForkServerContext: ...
99     @overload
100     def get_context(method: str) -> BaseContext: ...
101
102 else:
103     @overload
104     def get_context(method: None = ...) -> DefaultContext: ...
105     @overload
106     def get_context(method: Literal["spawn"]) -> SpawnContext: ...
107     @overload
108     def get_context(method: str) -> BaseContext: ...