multiprocess-stubs 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- multiprocess_stubs-0.1.0/.gitignore +10 -0
- multiprocess_stubs-0.1.0/.python-version +1 -0
- multiprocess_stubs-0.1.0/LICENSE.txt +21 -0
- multiprocess_stubs-0.1.0/PKG-INFO +47 -0
- multiprocess_stubs-0.1.0/README.md +33 -0
- multiprocess_stubs-0.1.0/pyproject.toml +36 -0
- multiprocess_stubs-0.1.0/requirements-dev.lock +15 -0
- multiprocess_stubs-0.1.0/requirements.lock +15 -0
- multiprocess_stubs-0.1.0/src/multiprocess/__init__.pyi +90 -0
- multiprocess_stubs-0.1.0/src/multiprocess/connection.pyi +83 -0
- multiprocess_stubs-0.1.0/src/multiprocess/context.pyi +206 -0
- multiprocess_stubs-0.1.0/src/multiprocess/dummy/__init__.pyi +77 -0
- multiprocess_stubs-0.1.0/src/multiprocess/dummy/connection.pyi +39 -0
- multiprocess_stubs-0.1.0/src/multiprocess/forkserver.pyi +31 -0
- multiprocess_stubs-0.1.0/src/multiprocess/heap.pyi +36 -0
- multiprocess_stubs-0.1.0/src/multiprocess/managers.pyi +246 -0
- multiprocess_stubs-0.1.0/src/multiprocess/pool.pyi +103 -0
- multiprocess_stubs-0.1.0/src/multiprocess/popen_fork.pyi +23 -0
- multiprocess_stubs-0.1.0/src/multiprocess/popen_forkserver.pyi +16 -0
- multiprocess_stubs-0.1.0/src/multiprocess/popen_spawn_posix.pyi +20 -0
- multiprocess_stubs-0.1.0/src/multiprocess/popen_spawn_win32.pyi +30 -0
- multiprocess_stubs-0.1.0/src/multiprocess/process.pyi +39 -0
- multiprocess_stubs-0.1.0/src/multiprocess/queues.pyi +41 -0
- multiprocess_stubs-0.1.0/src/multiprocess/reduction.pyi +87 -0
- multiprocess_stubs-0.1.0/src/multiprocess/resource_sharer.pyi +20 -0
- multiprocess_stubs-0.1.0/src/multiprocess/resource_tracker.pyi +18 -0
- multiprocess_stubs-0.1.0/src/multiprocess/shared_memory.pyi +44 -0
- multiprocess_stubs-0.1.0/src/multiprocess/sharedctypes.pyi +129 -0
- multiprocess_stubs-0.1.0/src/multiprocess/spawn.pyi +32 -0
- multiprocess_stubs-0.1.0/src/multiprocess/synchronize.pyi +59 -0
- multiprocess_stubs-0.1.0/src/multiprocess/util.pyi +98 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.12.3
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Yichao Zhou
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: multiprocess-stubs
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Type stubs for the multiprocess library.
|
|
5
|
+
Project-URL: Homepage, https://github.com/zhou13/multiprocess-stub
|
|
6
|
+
Project-URL: Issues, https://github.com/zhou13/multiprocess-stub/issues
|
|
7
|
+
Author-email: Yichao Zhou <zyc@berkeley.edu>
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Requires-Python: >=3.8
|
|
12
|
+
Requires-Dist: multiprocess
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
|
|
15
|
+
# multiprocess-stubs
|
|
16
|
+
|
|
17
|
+
[](https://pypi.python.org/pypi/multiprocess-stubs)
|
|
18
|
+
[](https://github.com/zhou13/multiprocess-stubs/blob/master/LICENSE.txt)
|
|
19
|
+
|
|
20
|
+
Type stubs for the `multiprocess` library.
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pip install multiprocess-stubs
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Purpose
|
|
29
|
+
|
|
30
|
+
This package provides type stubs (`.pyi`) for the `multiprocess` library, enabling better type checking and IDE support for Python's multiprocessing functionality.
|
|
31
|
+
|
|
32
|
+
## Usage
|
|
33
|
+
|
|
34
|
+
Simply install the stubs, and your type checker (mypy, pyright) will use these type definitions when analyzing code that uses `multiprocess`.
|
|
35
|
+
|
|
36
|
+
## Compatibility
|
|
37
|
+
|
|
38
|
+
- Compatible with Python 3.8+
|
|
39
|
+
- Matches the type signature of the standard library `multiprocessing` module
|
|
40
|
+
|
|
41
|
+
## Development
|
|
42
|
+
|
|
43
|
+
Right now, most of this package is copied from https://github.com/python/typeshed/tree/main/stdlib/multiprocessing. Contributions to improve the type annotations are welcome.
|
|
44
|
+
|
|
45
|
+
## License
|
|
46
|
+
|
|
47
|
+
MIT License
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# multiprocess-stubs
|
|
2
|
+
|
|
3
|
+
[](https://pypi.python.org/pypi/multiprocess-stubs)
|
|
4
|
+
[](https://github.com/zhou13/multiprocess-stubs/blob/master/LICENSE.txt)
|
|
5
|
+
|
|
6
|
+
Type stubs for the `multiprocess` library.
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
pip install multiprocess-stubs
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Purpose
|
|
15
|
+
|
|
16
|
+
This package provides type stubs (`.pyi`) for the `multiprocess` library, enabling better type checking and IDE support for Python's multiprocessing functionality.
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
Simply install the stubs, and your type checker (mypy, pyright) will use these type definitions when analyzing code that uses `multiprocess`.
|
|
21
|
+
|
|
22
|
+
## Compatibility
|
|
23
|
+
|
|
24
|
+
- Compatible with Python 3.8+
|
|
25
|
+
- Matches the type signature of the standard library `multiprocessing` module
|
|
26
|
+
|
|
27
|
+
## Development
|
|
28
|
+
|
|
29
|
+
Right now, most of this package is copied from https://github.com/python/typeshed/tree/main/stdlib/multiprocessing. Contributions to improve the type annotations are welcome.
|
|
30
|
+
|
|
31
|
+
## License
|
|
32
|
+
|
|
33
|
+
MIT License
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "multiprocess-stubs"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Type stubs for the multiprocess library."
|
|
5
|
+
authors = [
|
|
6
|
+
{ name = "Yichao Zhou", email = "zyc@berkeley.edu" }
|
|
7
|
+
]
|
|
8
|
+
dependencies = [
|
|
9
|
+
"multiprocess",
|
|
10
|
+
]
|
|
11
|
+
readme = "README.md"
|
|
12
|
+
requires-python = ">= 3.8"
|
|
13
|
+
classifiers = [
|
|
14
|
+
"Programming Language :: Python :: 3",
|
|
15
|
+
"License :: OSI Approved :: MIT License",
|
|
16
|
+
"Operating System :: OS Independent",
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
[project.urls]
|
|
20
|
+
Homepage = "https://github.com/zhou13/multiprocess-stub"
|
|
21
|
+
Issues = "https://github.com/zhou13/multiprocess-stub/issues"
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
[build-system]
|
|
25
|
+
requires = ["hatchling"]
|
|
26
|
+
build-backend = "hatchling.build"
|
|
27
|
+
|
|
28
|
+
[tool.rye]
|
|
29
|
+
managed = true
|
|
30
|
+
dev-dependencies = []
|
|
31
|
+
|
|
32
|
+
[tool.hatch.metadata]
|
|
33
|
+
allow-direct-references = true
|
|
34
|
+
|
|
35
|
+
[tool.hatch.build.targets.wheel]
|
|
36
|
+
packages = ["src/multiprocess"]
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# generated by rye
|
|
2
|
+
# use `rye lock` or `rye sync` to update this lockfile
|
|
3
|
+
#
|
|
4
|
+
# last locked with the following flags:
|
|
5
|
+
# pre: false
|
|
6
|
+
# features: []
|
|
7
|
+
# all-features: false
|
|
8
|
+
# with-sources: false
|
|
9
|
+
# generate-hashes: false
|
|
10
|
+
|
|
11
|
+
-e file:.
|
|
12
|
+
dill==0.3.9
|
|
13
|
+
# via multiprocess
|
|
14
|
+
multiprocess==0.70.17
|
|
15
|
+
# via multiprocess-stub
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# generated by rye
|
|
2
|
+
# use `rye lock` or `rye sync` to update this lockfile
|
|
3
|
+
#
|
|
4
|
+
# last locked with the following flags:
|
|
5
|
+
# pre: false
|
|
6
|
+
# features: []
|
|
7
|
+
# all-features: false
|
|
8
|
+
# with-sources: false
|
|
9
|
+
# generate-hashes: false
|
|
10
|
+
|
|
11
|
+
-e file:.
|
|
12
|
+
dill==0.3.9
|
|
13
|
+
# via multiprocess
|
|
14
|
+
multiprocess==0.70.17
|
|
15
|
+
# via multiprocess-stub
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
from multiprocessing import context, reduction as reducer
|
|
2
|
+
from multiprocessing.context import (
|
|
3
|
+
AuthenticationError as AuthenticationError,
|
|
4
|
+
BufferTooShort as BufferTooShort,
|
|
5
|
+
Process as Process,
|
|
6
|
+
ProcessError as ProcessError,
|
|
7
|
+
TimeoutError as TimeoutError,
|
|
8
|
+
)
|
|
9
|
+
from multiprocessing.process import (
|
|
10
|
+
active_children as active_children,
|
|
11
|
+
current_process as current_process,
|
|
12
|
+
parent_process as parent_process,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
# These are technically functions that return instances of these Queue classes.
|
|
16
|
+
# The stub here doesn't reflect reality exactly --
|
|
17
|
+
# while e.g. `multiprocessing.queues.Queue` is a class,
|
|
18
|
+
# `multiprocessing.Queue` is actually a function at runtime.
|
|
19
|
+
# Avoid using `multiprocessing.Queue` as a type annotation;
|
|
20
|
+
# use imports from multiprocessing.queues instead.
|
|
21
|
+
# See #4266 and #8450 for discussion.
|
|
22
|
+
from multiprocessing.queues import JoinableQueue as JoinableQueue, Queue as Queue, SimpleQueue as SimpleQueue
|
|
23
|
+
from multiprocessing.spawn import freeze_support as freeze_support
|
|
24
|
+
|
|
25
|
+
__all__ = [
|
|
26
|
+
"Array",
|
|
27
|
+
"AuthenticationError",
|
|
28
|
+
"Barrier",
|
|
29
|
+
"BoundedSemaphore",
|
|
30
|
+
"BufferTooShort",
|
|
31
|
+
"Condition",
|
|
32
|
+
"Event",
|
|
33
|
+
"JoinableQueue",
|
|
34
|
+
"Lock",
|
|
35
|
+
"Manager",
|
|
36
|
+
"Pipe",
|
|
37
|
+
"Pool",
|
|
38
|
+
"Process",
|
|
39
|
+
"ProcessError",
|
|
40
|
+
"Queue",
|
|
41
|
+
"RLock",
|
|
42
|
+
"RawArray",
|
|
43
|
+
"RawValue",
|
|
44
|
+
"Semaphore",
|
|
45
|
+
"SimpleQueue",
|
|
46
|
+
"TimeoutError",
|
|
47
|
+
"Value",
|
|
48
|
+
"active_children",
|
|
49
|
+
"allow_connection_pickling",
|
|
50
|
+
"cpu_count",
|
|
51
|
+
"current_process",
|
|
52
|
+
"freeze_support",
|
|
53
|
+
"get_all_start_methods",
|
|
54
|
+
"get_context",
|
|
55
|
+
"get_logger",
|
|
56
|
+
"get_start_method",
|
|
57
|
+
"log_to_stderr",
|
|
58
|
+
"parent_process",
|
|
59
|
+
"reducer",
|
|
60
|
+
"set_executable",
|
|
61
|
+
"set_forkserver_preload",
|
|
62
|
+
"set_start_method",
|
|
63
|
+
]
|
|
64
|
+
|
|
65
|
+
# These functions (really bound methods)
|
|
66
|
+
# are all autogenerated at runtime here: https://github.com/python/cpython/blob/600c65c094b0b48704d8ec2416930648052ba715/Lib/multiprocessing/__init__.py#L23
|
|
67
|
+
RawValue = context._default_context.RawValue
|
|
68
|
+
RawArray = context._default_context.RawArray
|
|
69
|
+
Value = context._default_context.Value
|
|
70
|
+
Array = context._default_context.Array
|
|
71
|
+
Barrier = context._default_context.Barrier
|
|
72
|
+
BoundedSemaphore = context._default_context.BoundedSemaphore
|
|
73
|
+
Condition = context._default_context.Condition
|
|
74
|
+
Event = context._default_context.Event
|
|
75
|
+
Lock = context._default_context.Lock
|
|
76
|
+
RLock = context._default_context.RLock
|
|
77
|
+
Semaphore = context._default_context.Semaphore
|
|
78
|
+
Pipe = context._default_context.Pipe
|
|
79
|
+
Pool = context._default_context.Pool
|
|
80
|
+
allow_connection_pickling = context._default_context.allow_connection_pickling
|
|
81
|
+
cpu_count = context._default_context.cpu_count
|
|
82
|
+
get_logger = context._default_context.get_logger
|
|
83
|
+
log_to_stderr = context._default_context.log_to_stderr
|
|
84
|
+
Manager = context._default_context.Manager
|
|
85
|
+
set_executable = context._default_context.set_executable
|
|
86
|
+
set_forkserver_preload = context._default_context.set_forkserver_preload
|
|
87
|
+
get_all_start_methods = context._default_context.get_all_start_methods
|
|
88
|
+
get_start_method = context._default_context.get_start_method
|
|
89
|
+
set_start_method = context._default_context.set_start_method
|
|
90
|
+
get_context = context._default_context.get_context
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import socket
|
|
2
|
+
import sys
|
|
3
|
+
from _typeshed import Incomplete, ReadableBuffer
|
|
4
|
+
from collections.abc import Iterable
|
|
5
|
+
from types import TracebackType
|
|
6
|
+
from typing import Any, Generic, SupportsIndex, TypeVar
|
|
7
|
+
from typing_extensions import Self, TypeAlias
|
|
8
|
+
|
|
9
|
+
__all__ = ["Client", "Listener", "Pipe", "wait"]
|
|
10
|
+
|
|
11
|
+
# https://docs.python.org/3/library/multiprocessing.html#address-formats
|
|
12
|
+
_Address: TypeAlias = str | tuple[str, int]
|
|
13
|
+
|
|
14
|
+
# Defaulting to Any to avoid forcing generics on a lot of pre-existing code
|
|
15
|
+
_SendT = TypeVar("_SendT", contravariant=True, default=Any)
|
|
16
|
+
_RecvT = TypeVar("_RecvT", covariant=True, default=Any)
|
|
17
|
+
|
|
18
|
+
class _ConnectionBase(Generic[_SendT, _RecvT]):
|
|
19
|
+
def __init__(self, handle: SupportsIndex, readable: bool = True, writable: bool = True) -> None: ...
|
|
20
|
+
@property
|
|
21
|
+
def closed(self) -> bool: ... # undocumented
|
|
22
|
+
@property
|
|
23
|
+
def readable(self) -> bool: ... # undocumented
|
|
24
|
+
@property
|
|
25
|
+
def writable(self) -> bool: ... # undocumented
|
|
26
|
+
def fileno(self) -> int: ...
|
|
27
|
+
def close(self) -> None: ...
|
|
28
|
+
def send_bytes(self, buf: ReadableBuffer, offset: int = 0, size: int | None = None) -> None: ...
|
|
29
|
+
def send(self, obj: _SendT) -> None: ...
|
|
30
|
+
def recv_bytes(self, maxlength: int | None = None) -> bytes: ...
|
|
31
|
+
def recv_bytes_into(self, buf: Any, offset: int = 0) -> int: ...
|
|
32
|
+
def recv(self) -> _RecvT: ...
|
|
33
|
+
def poll(self, timeout: float | None = 0.0) -> bool: ...
|
|
34
|
+
def __enter__(self) -> Self: ...
|
|
35
|
+
def __exit__(
|
|
36
|
+
self, exc_type: type[BaseException] | None, exc_value: BaseException | None, exc_tb: TracebackType | None
|
|
37
|
+
) -> None: ...
|
|
38
|
+
def __del__(self) -> None: ...
|
|
39
|
+
|
|
40
|
+
class Connection(_ConnectionBase[_SendT, _RecvT]): ...
|
|
41
|
+
|
|
42
|
+
if sys.platform == "win32":
|
|
43
|
+
class PipeConnection(_ConnectionBase[_SendT, _RecvT]): ...
|
|
44
|
+
|
|
45
|
+
class Listener:
|
|
46
|
+
def __init__(
|
|
47
|
+
self, address: _Address | None = None, family: str | None = None, backlog: int = 1, authkey: bytes | None = None
|
|
48
|
+
) -> None: ...
|
|
49
|
+
def accept(self) -> Connection[Incomplete, Incomplete]: ...
|
|
50
|
+
def close(self) -> None: ...
|
|
51
|
+
@property
|
|
52
|
+
def address(self) -> _Address: ...
|
|
53
|
+
@property
|
|
54
|
+
def last_accepted(self) -> _Address | None: ...
|
|
55
|
+
def __enter__(self) -> Self: ...
|
|
56
|
+
def __exit__(
|
|
57
|
+
self, exc_type: type[BaseException] | None, exc_value: BaseException | None, exc_tb: TracebackType | None
|
|
58
|
+
) -> None: ...
|
|
59
|
+
|
|
60
|
+
# Any: send and recv methods unused
|
|
61
|
+
if sys.version_info >= (3, 12):
|
|
62
|
+
def deliver_challenge(connection: Connection[Any, Any], authkey: bytes, digest_name: str = "sha256") -> None: ...
|
|
63
|
+
|
|
64
|
+
else:
|
|
65
|
+
def deliver_challenge(connection: Connection[Any, Any], authkey: bytes) -> None: ...
|
|
66
|
+
|
|
67
|
+
def answer_challenge(connection: Connection[Any, Any], authkey: bytes) -> None: ...
|
|
68
|
+
def wait(
|
|
69
|
+
object_list: Iterable[Connection[_SendT, _RecvT] | socket.socket | int], timeout: float | None = None
|
|
70
|
+
) -> list[Connection[_SendT, _RecvT] | socket.socket | int]: ...
|
|
71
|
+
def Client(address: _Address, family: str | None = None, authkey: bytes | None = None) -> Connection[Any, Any]: ...
|
|
72
|
+
|
|
73
|
+
# N.B. Keep this in sync with multiprocessing.context.BaseContext.Pipe.
|
|
74
|
+
# _ConnectionBase is the common base class of Connection and PipeConnection
|
|
75
|
+
# and can be used in cross-platform code.
|
|
76
|
+
#
|
|
77
|
+
# The two connections should have the same generic types but inverted (Connection[_T1, _T2], Connection[_T2, _T1]).
|
|
78
|
+
# However, TypeVars scoped entirely within a return annotation is unspecified in the spec.
|
|
79
|
+
if sys.platform != "win32":
|
|
80
|
+
def Pipe(duplex: bool = True) -> tuple[Connection[Any, Any], Connection[Any, Any]]: ...
|
|
81
|
+
|
|
82
|
+
else:
|
|
83
|
+
def Pipe(duplex: bool = True) -> tuple[PipeConnection[Any, Any], PipeConnection[Any, Any]]: ...
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import ctypes
|
|
2
|
+
import sys
|
|
3
|
+
from _ctypes import _CData
|
|
4
|
+
from collections.abc import Callable, Iterable, Sequence
|
|
5
|
+
from ctypes import _SimpleCData, c_char
|
|
6
|
+
from logging import Logger, _Level as _LoggingLevel
|
|
7
|
+
from multiprocessing import popen_fork, popen_forkserver, popen_spawn_posix, popen_spawn_win32, queues, synchronize
|
|
8
|
+
from multiprocessing.managers import SyncManager
|
|
9
|
+
from multiprocessing.pool import Pool as _Pool
|
|
10
|
+
from multiprocessing.process import BaseProcess
|
|
11
|
+
from multiprocessing.sharedctypes import Synchronized, SynchronizedArray, SynchronizedString
|
|
12
|
+
from typing import Any, ClassVar, Literal, TypeVar, overload
|
|
13
|
+
from typing_extensions import TypeAlias
|
|
14
|
+
|
|
15
|
+
if sys.platform != "win32":
|
|
16
|
+
from multiprocessing.connection import Connection
|
|
17
|
+
else:
|
|
18
|
+
from multiprocessing.connection import PipeConnection
|
|
19
|
+
|
|
20
|
+
__all__ = ()
|
|
21
|
+
|
|
22
|
+
_LockLike: TypeAlias = synchronize.Lock | synchronize.RLock
|
|
23
|
+
_T = TypeVar("_T")
|
|
24
|
+
_CT = TypeVar("_CT", bound=_CData)
|
|
25
|
+
|
|
26
|
+
class ProcessError(Exception): ...
|
|
27
|
+
class BufferTooShort(ProcessError): ...
|
|
28
|
+
class TimeoutError(ProcessError): ...
|
|
29
|
+
class AuthenticationError(ProcessError): ...
|
|
30
|
+
|
|
31
|
+
class BaseContext:
|
|
32
|
+
ProcessError: ClassVar[type[ProcessError]]
|
|
33
|
+
BufferTooShort: ClassVar[type[BufferTooShort]]
|
|
34
|
+
TimeoutError: ClassVar[type[TimeoutError]]
|
|
35
|
+
AuthenticationError: ClassVar[type[AuthenticationError]]
|
|
36
|
+
|
|
37
|
+
# N.B. The methods below are applied at runtime to generate
|
|
38
|
+
# multiprocessing.*, so the signatures should be identical (modulo self).
|
|
39
|
+
@staticmethod
|
|
40
|
+
def current_process() -> BaseProcess: ...
|
|
41
|
+
@staticmethod
|
|
42
|
+
def parent_process() -> BaseProcess | None: ...
|
|
43
|
+
@staticmethod
|
|
44
|
+
def active_children() -> list[BaseProcess]: ...
|
|
45
|
+
def cpu_count(self) -> int: ...
|
|
46
|
+
def Manager(self) -> SyncManager: ...
|
|
47
|
+
|
|
48
|
+
# N.B. Keep this in sync with multiprocessing.connection.Pipe.
|
|
49
|
+
# _ConnectionBase is the common base class of Connection and PipeConnection
|
|
50
|
+
# and can be used in cross-platform code.
|
|
51
|
+
#
|
|
52
|
+
# The two connections should have the same generic types but inverted (Connection[_T1, _T2], Connection[_T2, _T1]).
|
|
53
|
+
# However, TypeVars scoped entirely within a return annotation is unspecified in the spec.
|
|
54
|
+
if sys.platform != "win32":
|
|
55
|
+
def Pipe(self, duplex: bool = True) -> tuple[Connection[Any, Any], Connection[Any, Any]]: ...
|
|
56
|
+
else:
|
|
57
|
+
def Pipe(self, duplex: bool = True) -> tuple[PipeConnection[Any, Any], PipeConnection[Any, Any]]: ...
|
|
58
|
+
|
|
59
|
+
def Barrier(
|
|
60
|
+
self, parties: int, action: Callable[..., object] | None = None, timeout: float | None = None
|
|
61
|
+
) -> synchronize.Barrier: ...
|
|
62
|
+
def BoundedSemaphore(self, value: int = 1) -> synchronize.BoundedSemaphore: ...
|
|
63
|
+
def Condition(self, lock: _LockLike | None = None) -> synchronize.Condition: ...
|
|
64
|
+
def Event(self) -> synchronize.Event: ...
|
|
65
|
+
def Lock(self) -> synchronize.Lock: ...
|
|
66
|
+
def RLock(self) -> synchronize.RLock: ...
|
|
67
|
+
def Semaphore(self, value: int = 1) -> synchronize.Semaphore: ...
|
|
68
|
+
def Queue(self, maxsize: int = 0) -> queues.Queue[Any]: ...
|
|
69
|
+
def JoinableQueue(self, maxsize: int = 0) -> queues.JoinableQueue[Any]: ...
|
|
70
|
+
def SimpleQueue(self) -> queues.SimpleQueue[Any]: ...
|
|
71
|
+
def Pool(
|
|
72
|
+
self,
|
|
73
|
+
processes: int | None = None,
|
|
74
|
+
initializer: Callable[..., object] | None = None,
|
|
75
|
+
initargs: Iterable[Any] = (),
|
|
76
|
+
maxtasksperchild: int | None = None,
|
|
77
|
+
) -> _Pool: ...
|
|
78
|
+
@overload
|
|
79
|
+
def RawValue(self, typecode_or_type: type[_CT], *args: Any) -> _CT: ...
|
|
80
|
+
@overload
|
|
81
|
+
def RawValue(self, typecode_or_type: str, *args: Any) -> Any: ...
|
|
82
|
+
@overload
|
|
83
|
+
def RawArray(self, typecode_or_type: type[_CT], size_or_initializer: int | Sequence[Any]) -> ctypes.Array[_CT]: ...
|
|
84
|
+
@overload
|
|
85
|
+
def RawArray(self, typecode_or_type: str, size_or_initializer: int | Sequence[Any]) -> Any: ...
|
|
86
|
+
@overload
|
|
87
|
+
def Value(
|
|
88
|
+
self, typecode_or_type: type[_SimpleCData[_T]], *args: Any, lock: Literal[True] | _LockLike = True
|
|
89
|
+
) -> Synchronized[_T]: ...
|
|
90
|
+
@overload
|
|
91
|
+
def Value(self, typecode_or_type: type[_CT], *args: Any, lock: Literal[False]) -> Synchronized[_CT]: ...
|
|
92
|
+
@overload
|
|
93
|
+
def Value(self, typecode_or_type: type[_CT], *args: Any, lock: Literal[True] | _LockLike = True) -> Synchronized[_CT]: ...
|
|
94
|
+
@overload
|
|
95
|
+
def Value(self, typecode_or_type: str, *args: Any, lock: Literal[True] | _LockLike = True) -> Synchronized[Any]: ...
|
|
96
|
+
@overload
|
|
97
|
+
def Value(self, typecode_or_type: str | type[_CData], *args: Any, lock: bool | _LockLike = True) -> Any: ...
|
|
98
|
+
@overload
|
|
99
|
+
def Array(
|
|
100
|
+
self, typecode_or_type: type[_SimpleCData[_T]], size_or_initializer: int | Sequence[Any], *, lock: Literal[False]
|
|
101
|
+
) -> SynchronizedArray[_T]: ...
|
|
102
|
+
@overload
|
|
103
|
+
def Array(
|
|
104
|
+
self, typecode_or_type: type[c_char], size_or_initializer: int | Sequence[Any], *, lock: Literal[True] | _LockLike = True
|
|
105
|
+
) -> SynchronizedString: ...
|
|
106
|
+
@overload
|
|
107
|
+
def Array(
|
|
108
|
+
self,
|
|
109
|
+
typecode_or_type: type[_SimpleCData[_T]],
|
|
110
|
+
size_or_initializer: int | Sequence[Any],
|
|
111
|
+
*,
|
|
112
|
+
lock: Literal[True] | _LockLike = True,
|
|
113
|
+
) -> SynchronizedArray[_T]: ...
|
|
114
|
+
@overload
|
|
115
|
+
def Array(
|
|
116
|
+
self, typecode_or_type: str, size_or_initializer: int | Sequence[Any], *, lock: Literal[True] | _LockLike = True
|
|
117
|
+
) -> SynchronizedArray[Any]: ...
|
|
118
|
+
@overload
|
|
119
|
+
def Array(
|
|
120
|
+
self, typecode_or_type: str | type[_CData], size_or_initializer: int | Sequence[Any], *, lock: bool | _LockLike = True
|
|
121
|
+
) -> Any: ...
|
|
122
|
+
def freeze_support(self) -> None: ...
|
|
123
|
+
def get_logger(self) -> Logger: ...
|
|
124
|
+
def log_to_stderr(self, level: _LoggingLevel | None = None) -> Logger: ...
|
|
125
|
+
def allow_connection_pickling(self) -> None: ...
|
|
126
|
+
def set_executable(self, executable: str) -> None: ...
|
|
127
|
+
def set_forkserver_preload(self, module_names: list[str]) -> None: ...
|
|
128
|
+
if sys.platform != "win32":
|
|
129
|
+
@overload
|
|
130
|
+
def get_context(self, method: None = None) -> DefaultContext: ...
|
|
131
|
+
@overload
|
|
132
|
+
def get_context(self, method: Literal["spawn"]) -> SpawnContext: ...
|
|
133
|
+
@overload
|
|
134
|
+
def get_context(self, method: Literal["fork"]) -> ForkContext: ...
|
|
135
|
+
@overload
|
|
136
|
+
def get_context(self, method: Literal["forkserver"]) -> ForkServerContext: ...
|
|
137
|
+
@overload
|
|
138
|
+
def get_context(self, method: str) -> BaseContext: ...
|
|
139
|
+
else:
|
|
140
|
+
@overload
|
|
141
|
+
def get_context(self, method: None = None) -> DefaultContext: ...
|
|
142
|
+
@overload
|
|
143
|
+
def get_context(self, method: Literal["spawn"]) -> SpawnContext: ...
|
|
144
|
+
@overload
|
|
145
|
+
def get_context(self, method: str) -> BaseContext: ...
|
|
146
|
+
|
|
147
|
+
@overload
|
|
148
|
+
def get_start_method(self, allow_none: Literal[False] = False) -> str: ...
|
|
149
|
+
@overload
|
|
150
|
+
def get_start_method(self, allow_none: bool) -> str | None: ...
|
|
151
|
+
def set_start_method(self, method: str | None, force: bool = False) -> None: ...
|
|
152
|
+
@property
|
|
153
|
+
def reducer(self) -> str: ...
|
|
154
|
+
@reducer.setter
|
|
155
|
+
def reducer(self, reduction: str) -> None: ...
|
|
156
|
+
def _check_available(self) -> None: ...
|
|
157
|
+
|
|
158
|
+
class Process(BaseProcess):
|
|
159
|
+
_start_method: str | None
|
|
160
|
+
@staticmethod
|
|
161
|
+
def _Popen(process_obj: BaseProcess) -> DefaultContext: ...
|
|
162
|
+
|
|
163
|
+
class DefaultContext(BaseContext):
|
|
164
|
+
Process: ClassVar[type[Process]]
|
|
165
|
+
def __init__(self, context: BaseContext) -> None: ...
|
|
166
|
+
def get_start_method(self, allow_none: bool = False) -> str: ...
|
|
167
|
+
def get_all_start_methods(self) -> list[str]: ...
|
|
168
|
+
|
|
169
|
+
_default_context: DefaultContext
|
|
170
|
+
|
|
171
|
+
class SpawnProcess(BaseProcess):
|
|
172
|
+
_start_method: str
|
|
173
|
+
if sys.platform != "win32":
|
|
174
|
+
@staticmethod
|
|
175
|
+
def _Popen(process_obj: BaseProcess) -> popen_spawn_posix.Popen: ...
|
|
176
|
+
else:
|
|
177
|
+
@staticmethod
|
|
178
|
+
def _Popen(process_obj: BaseProcess) -> popen_spawn_win32.Popen: ...
|
|
179
|
+
|
|
180
|
+
class SpawnContext(BaseContext):
|
|
181
|
+
_name: str
|
|
182
|
+
Process: ClassVar[type[SpawnProcess]]
|
|
183
|
+
|
|
184
|
+
if sys.platform != "win32":
|
|
185
|
+
class ForkProcess(BaseProcess):
|
|
186
|
+
_start_method: str
|
|
187
|
+
@staticmethod
|
|
188
|
+
def _Popen(process_obj: BaseProcess) -> popen_fork.Popen: ...
|
|
189
|
+
|
|
190
|
+
class ForkServerProcess(BaseProcess):
|
|
191
|
+
_start_method: str
|
|
192
|
+
@staticmethod
|
|
193
|
+
def _Popen(process_obj: BaseProcess) -> popen_forkserver.Popen: ...
|
|
194
|
+
|
|
195
|
+
class ForkContext(BaseContext):
|
|
196
|
+
_name: str
|
|
197
|
+
Process: ClassVar[type[ForkProcess]]
|
|
198
|
+
|
|
199
|
+
class ForkServerContext(BaseContext):
|
|
200
|
+
_name: str
|
|
201
|
+
Process: ClassVar[type[ForkServerProcess]]
|
|
202
|
+
|
|
203
|
+
def _force_start_method(method: str) -> None: ...
|
|
204
|
+
def get_spawning_popen() -> Any | None: ...
|
|
205
|
+
def set_spawning_popen(popen: Any) -> None: ...
|
|
206
|
+
def assert_spawning(obj: Any) -> None: ...
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import array
|
|
2
|
+
import threading
|
|
3
|
+
import weakref
|
|
4
|
+
from collections.abc import Callable, Iterable, Mapping, Sequence
|
|
5
|
+
from queue import Queue as Queue
|
|
6
|
+
from threading import (
|
|
7
|
+
Barrier as Barrier,
|
|
8
|
+
BoundedSemaphore as BoundedSemaphore,
|
|
9
|
+
Condition as Condition,
|
|
10
|
+
Event as Event,
|
|
11
|
+
Lock as Lock,
|
|
12
|
+
RLock as RLock,
|
|
13
|
+
Semaphore as Semaphore,
|
|
14
|
+
)
|
|
15
|
+
from typing import Any, Literal
|
|
16
|
+
|
|
17
|
+
from .connection import Pipe as Pipe
|
|
18
|
+
|
|
19
|
+
__all__ = [
|
|
20
|
+
"Process",
|
|
21
|
+
"current_process",
|
|
22
|
+
"active_children",
|
|
23
|
+
"freeze_support",
|
|
24
|
+
"Lock",
|
|
25
|
+
"RLock",
|
|
26
|
+
"Semaphore",
|
|
27
|
+
"BoundedSemaphore",
|
|
28
|
+
"Condition",
|
|
29
|
+
"Event",
|
|
30
|
+
"Barrier",
|
|
31
|
+
"Queue",
|
|
32
|
+
"Manager",
|
|
33
|
+
"Pipe",
|
|
34
|
+
"Pool",
|
|
35
|
+
"JoinableQueue",
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
JoinableQueue = Queue
|
|
39
|
+
|
|
40
|
+
class DummyProcess(threading.Thread):
|
|
41
|
+
_children: weakref.WeakKeyDictionary[Any, Any]
|
|
42
|
+
_parent: threading.Thread
|
|
43
|
+
_pid: None
|
|
44
|
+
_start_called: int
|
|
45
|
+
@property
|
|
46
|
+
def exitcode(self) -> Literal[0] | None: ...
|
|
47
|
+
def __init__(
|
|
48
|
+
self,
|
|
49
|
+
group: Any = None,
|
|
50
|
+
target: Callable[..., object] | None = None,
|
|
51
|
+
name: str | None = None,
|
|
52
|
+
args: Iterable[Any] = (),
|
|
53
|
+
kwargs: Mapping[str, Any] = {},
|
|
54
|
+
) -> None: ...
|
|
55
|
+
|
|
56
|
+
Process = DummyProcess
|
|
57
|
+
|
|
58
|
+
class Namespace:
|
|
59
|
+
def __init__(self, **kwds: Any) -> None: ...
|
|
60
|
+
def __getattr__(self, name: str, /) -> Any: ...
|
|
61
|
+
def __setattr__(self, name: str, value: Any, /) -> None: ...
|
|
62
|
+
|
|
63
|
+
class Value:
|
|
64
|
+
_typecode: Any
|
|
65
|
+
_value: Any
|
|
66
|
+
value: Any
|
|
67
|
+
def __init__(self, typecode: Any, value: Any, lock: Any = True) -> None: ...
|
|
68
|
+
|
|
69
|
+
def Array(typecode: Any, sequence: Sequence[Any], lock: Any = True) -> array.array[Any]: ...
|
|
70
|
+
def Manager() -> Any: ...
|
|
71
|
+
def Pool(processes: int | None = None, initializer: Callable[..., object] | None = None, initargs: Iterable[Any] = ()) -> Any: ...
|
|
72
|
+
def active_children() -> list[Any]: ...
|
|
73
|
+
|
|
74
|
+
current_process = threading.current_thread
|
|
75
|
+
|
|
76
|
+
def freeze_support() -> None: ...
|
|
77
|
+
def shutdown() -> None: ...
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
from multiprocessing.connection import _Address
|
|
2
|
+
from queue import Queue
|
|
3
|
+
from types import TracebackType
|
|
4
|
+
from typing import Any
|
|
5
|
+
from typing_extensions import Self
|
|
6
|
+
|
|
7
|
+
__all__ = ["Client", "Listener", "Pipe"]
|
|
8
|
+
|
|
9
|
+
families: list[None]
|
|
10
|
+
|
|
11
|
+
class Connection:
|
|
12
|
+
_in: Any
|
|
13
|
+
_out: Any
|
|
14
|
+
recv: Any
|
|
15
|
+
recv_bytes: Any
|
|
16
|
+
send: Any
|
|
17
|
+
send_bytes: Any
|
|
18
|
+
def __enter__(self) -> Self: ...
|
|
19
|
+
def __exit__(
|
|
20
|
+
self, exc_type: type[BaseException] | None, exc_value: BaseException | None, exc_tb: TracebackType | None
|
|
21
|
+
) -> None: ...
|
|
22
|
+
def __init__(self, _in: Any, _out: Any) -> None: ...
|
|
23
|
+
def close(self) -> None: ...
|
|
24
|
+
def poll(self, timeout: float = 0.0) -> bool: ...
|
|
25
|
+
|
|
26
|
+
class Listener:
|
|
27
|
+
_backlog_queue: Queue[Any] | None
|
|
28
|
+
@property
|
|
29
|
+
def address(self) -> Queue[Any] | None: ...
|
|
30
|
+
def __enter__(self) -> Self: ...
|
|
31
|
+
def __exit__(
|
|
32
|
+
self, exc_type: type[BaseException] | None, exc_value: BaseException | None, exc_tb: TracebackType | None
|
|
33
|
+
) -> None: ...
|
|
34
|
+
def __init__(self, address: _Address | None = None, family: int | None = None, backlog: int = 1) -> None: ...
|
|
35
|
+
def accept(self) -> Connection: ...
|
|
36
|
+
def close(self) -> None: ...
|
|
37
|
+
|
|
38
|
+
def Client(address: _Address) -> Connection: ...
|
|
39
|
+
def Pipe(duplex: bool = True) -> tuple[Connection, Connection]: ...
|