multiprocess-stubs 0.1.0__py3-none-any.whl

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.
@@ -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]: ...
@@ -0,0 +1,31 @@
1
+ from _typeshed import FileDescriptorLike, Unused
2
+ from collections.abc import Sequence
3
+ from struct import Struct
4
+ from typing import Any, Final
5
+
6
+ __all__ = ["ensure_running", "get_inherited_fds", "connect_to_new_process", "set_forkserver_preload"]
7
+
8
+ MAXFDS_TO_SEND: Final = 256
9
+ SIGNED_STRUCT: Final[Struct]
10
+
11
+ class ForkServer:
12
+ def set_forkserver_preload(self, modules_names: list[str]) -> None: ...
13
+ def get_inherited_fds(self) -> list[int] | None: ...
14
+ def connect_to_new_process(self, fds: Sequence[int]) -> tuple[int, int]: ...
15
+ def ensure_running(self) -> None: ...
16
+
17
+ def main(
18
+ listener_fd: int | None,
19
+ alive_r: FileDescriptorLike,
20
+ preload: Sequence[str],
21
+ main_path: str | None = None,
22
+ sys_path: Unused = None,
23
+ ) -> None: ...
24
+ def read_signed(fd: int) -> Any: ...
25
+ def write_signed(fd: int, n: int) -> None: ...
26
+
27
+ _forkserver: ForkServer
28
+ ensure_running = _forkserver.ensure_running
29
+ get_inherited_fds = _forkserver.get_inherited_fds
30
+ connect_to_new_process = _forkserver.connect_to_new_process
31
+ set_forkserver_preload = _forkserver.set_forkserver_preload
multiprocess/heap.pyi ADDED
@@ -0,0 +1,36 @@
1
+ import sys
2
+ from _typeshed import Incomplete
3
+ from collections.abc import Callable
4
+ from mmap import mmap
5
+ from typing import Protocol
6
+ from typing_extensions import TypeAlias
7
+
8
+ __all__ = ["BufferWrapper"]
9
+
10
+ class Arena:
11
+ size: int
12
+ buffer: mmap
13
+ if sys.platform == "win32":
14
+ name: str
15
+ def __init__(self, size: int) -> None: ...
16
+ else:
17
+ fd: int
18
+ def __init__(self, size: int, fd: int = -1) -> None: ...
19
+
20
+ _Block: TypeAlias = tuple[Arena, int, int]
21
+
22
+ if sys.platform != "win32":
23
+ class _SupportsDetach(Protocol):
24
+ def detach(self) -> int: ...
25
+
26
+ def reduce_arena(a: Arena) -> tuple[Callable[[int, _SupportsDetach], Arena], tuple[int, Incomplete]]: ...
27
+ def rebuild_arena(size: int, dupfd: _SupportsDetach) -> Arena: ...
28
+
29
+ class Heap:
30
+ def __init__(self, size: int = ...) -> None: ...
31
+ def free(self, block: _Block) -> None: ...
32
+ def malloc(self, size: int) -> _Block: ...
33
+
34
+ class BufferWrapper:
35
+ def __init__(self, size: int) -> None: ...
36
+ def create_memoryview(self) -> memoryview: ...