basedpyright 1.18.4 → 1.19.0
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.
- package/dist/pyright-langserver.js +1 -1
- package/dist/pyright-langserver.js.map +1 -1
- package/dist/pyright.js +1 -1
- package/dist/pyright.js.map +1 -1
- package/dist/typeshed-fallback/stdlib/_collections_abc.pyi +6 -2
- package/dist/typeshed-fallback/stdlib/_csv.pyi +1 -63
- package/dist/typeshed-fallback/stdlib/_ctypes.pyi +29 -3
- package/dist/typeshed-fallback/stdlib/_interpchannels.pyi +258 -86
- package/dist/typeshed-fallback/stdlib/_interpqueues.pyi +100 -16
- package/dist/typeshed-fallback/stdlib/_interpreters.pyi +204 -50
- package/dist/typeshed-fallback/stdlib/_json.pyi +1 -1
- package/dist/typeshed-fallback/stdlib/_socket.pyi +5 -26
- package/dist/typeshed-fallback/stdlib/_sqlite3.pyi +24 -9
- package/dist/typeshed-fallback/stdlib/_stat.pyi +13 -2
- package/dist/typeshed-fallback/stdlib/_thread.pyi +35 -93
- package/dist/typeshed-fallback/stdlib/asyncio/futures.pyi +3 -1
- package/dist/typeshed-fallback/stdlib/atexit.pyi +6 -20
- package/dist/typeshed-fallback/stdlib/builtins.pyi +250 -251
- package/dist/typeshed-fallback/stdlib/collections/__init__.pyi +8 -7
- package/dist/typeshed-fallback/stdlib/datetime.pyi +9 -3
- package/dist/typeshed-fallback/stdlib/dbm/sqlite3.pyi +29 -29
- package/dist/typeshed-fallback/stdlib/dis.pyi +33 -7
- package/dist/typeshed-fallback/stdlib/functools.pyi +2 -2
- package/dist/typeshed-fallback/stdlib/gc.pyi +5 -11
- package/dist/typeshed-fallback/stdlib/importlib/metadata/__init__.pyi +17 -2
- package/dist/typeshed-fallback/stdlib/importlib/metadata/diagnose.pyi +2 -2
- package/dist/typeshed-fallback/stdlib/importlib/resources/_functional.pyi +30 -30
- package/dist/typeshed-fallback/stdlib/io.pyi +3 -1
- package/dist/typeshed-fallback/stdlib/ipaddress.pyi +8 -1
- package/dist/typeshed-fallback/stdlib/itertools.pyi +3 -6
- package/dist/typeshed-fallback/stdlib/marshal.pyi +61 -4
- package/dist/typeshed-fallback/stdlib/math.pyi +7 -1
- package/dist/typeshed-fallback/stdlib/mmap.pyi +1 -1
- package/dist/typeshed-fallback/stdlib/multiprocessing/managers.pyi +14 -2
- package/dist/typeshed-fallback/stdlib/os/__init__.pyi +43 -9
- package/dist/typeshed-fallback/stdlib/posixpath.pyi +14 -2
- package/dist/typeshed-fallback/stdlib/signal.pyi +2 -3
- package/dist/typeshed-fallback/stdlib/sqlite3/__init__.pyi +54 -6
- package/dist/typeshed-fallback/stdlib/sys/__init__.pyi +11 -17
- package/dist/typeshed-fallback/stdlib/threading.pyi +44 -16
- package/dist/typeshed-fallback/stdlib/time.pyi +2 -10
- package/dist/typeshed-fallback/stdlib/types.pyi +31 -13
- package/dist/typeshed-fallback/stdlib/typing.pyi +6 -2
- package/dist/typeshed-fallback/stdlib/unicodedata.pyi +2 -2
- package/package.json +1 -1
|
@@ -1,50 +1,204 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
def
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
def
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
1
|
+
"""
|
|
2
|
+
This module provides primitive operations to manage Python interpreters.
|
|
3
|
+
The 'interpreters' module provides a more convenient interface.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
import types
|
|
7
|
+
from collections.abc import Callable, Mapping
|
|
8
|
+
from typing import Final, Literal, SupportsIndex
|
|
9
|
+
from typing_extensions import TypeAlias
|
|
10
|
+
|
|
11
|
+
_Configs: TypeAlias = Literal["default", "isolated", "legacy", "empty", ""]
|
|
12
|
+
|
|
13
|
+
class InterpreterError(Exception):
|
|
14
|
+
"""A cross-interpreter operation failed"""
|
|
15
|
+
...
|
|
16
|
+
class InterpreterNotFoundError(InterpreterError):
|
|
17
|
+
"""An interpreter was not found"""
|
|
18
|
+
...
|
|
19
|
+
class NotShareableError(Exception): ...
|
|
20
|
+
|
|
21
|
+
class CrossInterpreterBufferView:
|
|
22
|
+
def __buffer__(self, flags: int, /) -> memoryview:
|
|
23
|
+
"""Return a buffer object that exposes the underlying memory of the object."""
|
|
24
|
+
...
|
|
25
|
+
|
|
26
|
+
def new_config(name: _Configs = "isolated", /, **overides: object) -> types.SimpleNamespace:
|
|
27
|
+
"""
|
|
28
|
+
new_config(name='isolated', /, **overrides) -> type.SimpleNamespace
|
|
29
|
+
|
|
30
|
+
Return a representation of a new PyInterpreterConfig.
|
|
31
|
+
|
|
32
|
+
The name determines the initial values of the config. Supported named
|
|
33
|
+
configs are: default, isolated, legacy, and empty.
|
|
34
|
+
|
|
35
|
+
Any keyword arguments are set on the corresponding config fields,
|
|
36
|
+
overriding the initial values.
|
|
37
|
+
"""
|
|
38
|
+
...
|
|
39
|
+
def create(config: types.SimpleNamespace | _Configs | None = "isolated", *, reqrefs: bool = False) -> int:
|
|
40
|
+
"""
|
|
41
|
+
create([config], *, reqrefs=False) -> ID
|
|
42
|
+
|
|
43
|
+
Create a new interpreter and return a unique generated ID.
|
|
44
|
+
|
|
45
|
+
The caller is responsible for destroying the interpreter before exiting,
|
|
46
|
+
typically by using _interpreters.destroy(). This can be managed
|
|
47
|
+
automatically by passing "reqrefs=True" and then using _incref() and
|
|
48
|
+
_decref()` appropriately.
|
|
49
|
+
|
|
50
|
+
"config" must be a valid interpreter config or the name of a
|
|
51
|
+
predefined config ("isolated" or "legacy"). The default
|
|
52
|
+
is "isolated".
|
|
53
|
+
"""
|
|
54
|
+
...
|
|
55
|
+
def destroy(id: SupportsIndex, *, restrict: bool = False) -> None:
|
|
56
|
+
"""
|
|
57
|
+
destroy(id, *, restrict=False)
|
|
58
|
+
|
|
59
|
+
Destroy the identified interpreter.
|
|
60
|
+
|
|
61
|
+
Attempting to destroy the current interpreter raises InterpreterError.
|
|
62
|
+
So does an unrecognized ID.
|
|
63
|
+
"""
|
|
64
|
+
...
|
|
65
|
+
def list_all(*, require_ready: bool) -> list[tuple[int, int]]:
|
|
66
|
+
"""
|
|
67
|
+
list_all() -> [(ID, whence)]
|
|
68
|
+
|
|
69
|
+
Return a list containing the ID of every existing interpreter.
|
|
70
|
+
"""
|
|
71
|
+
...
|
|
72
|
+
def get_current() -> tuple[int, int]:
|
|
73
|
+
"""
|
|
74
|
+
get_current() -> (ID, whence)
|
|
75
|
+
|
|
76
|
+
Return the ID of current interpreter.
|
|
77
|
+
"""
|
|
78
|
+
...
|
|
79
|
+
def get_main() -> tuple[int, int]:
|
|
80
|
+
"""
|
|
81
|
+
get_main() -> (ID, whence)
|
|
82
|
+
|
|
83
|
+
Return the ID of main interpreter.
|
|
84
|
+
"""
|
|
85
|
+
...
|
|
86
|
+
def is_running(id: SupportsIndex, *, restrict: bool = False) -> bool:
|
|
87
|
+
"""
|
|
88
|
+
is_running(id, *, restrict=False) -> bool
|
|
89
|
+
|
|
90
|
+
Return whether or not the identified interpreter is running.
|
|
91
|
+
"""
|
|
92
|
+
...
|
|
93
|
+
def get_config(id: SupportsIndex, *, restrict: bool = False) -> types.SimpleNamespace:
|
|
94
|
+
"""
|
|
95
|
+
get_config(id, *, restrict=False) -> types.SimpleNamespace
|
|
96
|
+
|
|
97
|
+
Return a representation of the config used to initialize the interpreter.
|
|
98
|
+
"""
|
|
99
|
+
...
|
|
100
|
+
def whence(id: SupportsIndex) -> int:
|
|
101
|
+
"""
|
|
102
|
+
whence(id) -> int
|
|
103
|
+
|
|
104
|
+
Return an identifier for where the interpreter was created.
|
|
105
|
+
"""
|
|
106
|
+
...
|
|
107
|
+
def exec(id: SupportsIndex, code: str, shared: bool | None = None, *, restrict: bool = False) -> None:
|
|
108
|
+
"""
|
|
109
|
+
exec(id, code, shared=None, *, restrict=False)
|
|
110
|
+
|
|
111
|
+
Execute the provided code in the identified interpreter.
|
|
112
|
+
This is equivalent to running the builtin exec() under the target
|
|
113
|
+
interpreter, using the __dict__ of its __main__ module as both
|
|
114
|
+
globals and locals.
|
|
115
|
+
|
|
116
|
+
"code" may be a string containing the text of a Python script.
|
|
117
|
+
|
|
118
|
+
Functions (and code objects) are also supported, with some restrictions.
|
|
119
|
+
The code/function must not take any arguments or be a closure
|
|
120
|
+
(i.e. have cell vars). Methods and other callables are not supported.
|
|
121
|
+
|
|
122
|
+
If a function is provided, its code object is used and all its state
|
|
123
|
+
is ignored, including its __globals__ dict.
|
|
124
|
+
"""
|
|
125
|
+
...
|
|
126
|
+
def call(
|
|
127
|
+
id: SupportsIndex,
|
|
128
|
+
callable: Callable[..., object],
|
|
129
|
+
args: tuple[object, ...] | None = None,
|
|
130
|
+
kwargs: dict[str, object] | None = None,
|
|
131
|
+
*,
|
|
132
|
+
restrict: bool = False,
|
|
133
|
+
) -> object:
|
|
134
|
+
"""
|
|
135
|
+
call(id, callable, args=None, kwargs=None, *, restrict=False)
|
|
136
|
+
|
|
137
|
+
Call the provided object in the identified interpreter.
|
|
138
|
+
Pass the given args and kwargs, if possible.
|
|
139
|
+
|
|
140
|
+
"callable" may be a plain function with no free vars that takes
|
|
141
|
+
no arguments.
|
|
142
|
+
|
|
143
|
+
The function's code object is used and all its state
|
|
144
|
+
is ignored, including its __globals__ dict.
|
|
145
|
+
"""
|
|
146
|
+
...
|
|
147
|
+
def run_string(
|
|
148
|
+
id: SupportsIndex, script: str | types.CodeType | Callable[[], object], shared: bool | None = None, *, restrict: bool = False
|
|
149
|
+
) -> None:
|
|
150
|
+
"""
|
|
151
|
+
run_string(id, script, shared=None, *, restrict=False)
|
|
152
|
+
|
|
153
|
+
Execute the provided string in the identified interpreter.
|
|
154
|
+
|
|
155
|
+
(See _interpreters.exec().
|
|
156
|
+
"""
|
|
157
|
+
...
|
|
158
|
+
def run_func(
|
|
159
|
+
id: SupportsIndex, func: types.CodeType | Callable[[], object], shared: bool | None = None, *, restrict: bool = False
|
|
160
|
+
) -> None:
|
|
161
|
+
"""
|
|
162
|
+
run_func(id, func, shared=None, *, restrict=False)
|
|
163
|
+
|
|
164
|
+
Execute the body of the provided function in the identified interpreter.
|
|
165
|
+
Code objects are also supported. In both cases, closures and args
|
|
166
|
+
are not supported. Methods and other callables are not supported either.
|
|
167
|
+
|
|
168
|
+
(See _interpreters.exec().
|
|
169
|
+
"""
|
|
170
|
+
...
|
|
171
|
+
def set___main___attrs(id: SupportsIndex, updates: Mapping[str, object], *, restrict: bool = False) -> None:
|
|
172
|
+
"""
|
|
173
|
+
set___main___attrs(id, ns, *, restrict=False)
|
|
174
|
+
|
|
175
|
+
Bind the given attributes in the interpreter's __main__ module.
|
|
176
|
+
"""
|
|
177
|
+
...
|
|
178
|
+
def incref(id: SupportsIndex, *, implieslink: bool = False, restrict: bool = False) -> None: ...
|
|
179
|
+
def decref(id: SupportsIndex, *, restrict: bool = False) -> None: ...
|
|
180
|
+
def is_shareable(obj: object) -> bool:
|
|
181
|
+
"""
|
|
182
|
+
is_shareable(obj) -> bool
|
|
183
|
+
|
|
184
|
+
Return True if the object's data may be shared between interpreters and
|
|
185
|
+
False otherwise.
|
|
186
|
+
"""
|
|
187
|
+
...
|
|
188
|
+
def capture_exception(exc: BaseException | None = None) -> types.SimpleNamespace:
|
|
189
|
+
"""
|
|
190
|
+
capture_exception(exc=None) -> types.SimpleNamespace
|
|
191
|
+
|
|
192
|
+
Return a snapshot of an exception. If "exc" is None
|
|
193
|
+
then the current exception, if any, is used (but not cleared).
|
|
194
|
+
|
|
195
|
+
The returned snapshot is the same as what _interpreters.exec() returns.
|
|
196
|
+
"""
|
|
197
|
+
...
|
|
198
|
+
|
|
199
|
+
WHENCE_UNKNOWN: Final = 0
|
|
200
|
+
WHENCE_RUNTIME: Final = 1
|
|
201
|
+
WHENCE_LEGACY_CAPI: Final = 2
|
|
202
|
+
WHENCE_CAPI: Final = 3
|
|
203
|
+
WHENCE_XI: Final = 4
|
|
204
|
+
WHENCE_STDLIB: Final = 5
|
|
@@ -5,7 +5,7 @@ from typing import Any, final
|
|
|
5
5
|
|
|
6
6
|
@final
|
|
7
7
|
class make_encoder:
|
|
8
|
-
"""
|
|
8
|
+
"""Encoder(markers, default, encoder, indent, key_separator, item_separator, sort_keys, skipkeys, allow_nan)"""
|
|
9
9
|
@property
|
|
10
10
|
def sort_keys(self) -> bool:
|
|
11
11
|
"""sort_keys"""
|
|
@@ -1198,11 +1198,7 @@ def ntohl(x: int, /) -> int:
|
|
|
1198
1198
|
"""
|
|
1199
1199
|
...
|
|
1200
1200
|
def ntohs(x: int, /) -> int:
|
|
1201
|
-
"""
|
|
1202
|
-
ntohs(integer) -> integer
|
|
1203
|
-
|
|
1204
|
-
Convert a 16-bit unsigned integer from network to host byte order.
|
|
1205
|
-
"""
|
|
1201
|
+
"""Convert a 16-bit unsigned integer from network to host byte order."""
|
|
1206
1202
|
...
|
|
1207
1203
|
def htonl(x: int, /) -> int:
|
|
1208
1204
|
"""
|
|
@@ -1212,26 +1208,13 @@ def htonl(x: int, /) -> int:
|
|
|
1212
1208
|
"""
|
|
1213
1209
|
...
|
|
1214
1210
|
def htons(x: int, /) -> int:
|
|
1215
|
-
"""
|
|
1216
|
-
htons(integer) -> integer
|
|
1217
|
-
|
|
1218
|
-
Convert a 16-bit unsigned integer from host to network byte order.
|
|
1219
|
-
"""
|
|
1211
|
+
"""Convert a 16-bit unsigned integer from host to network byte order."""
|
|
1220
1212
|
...
|
|
1221
1213
|
def inet_aton(ip_addr: str, /) -> bytes:
|
|
1222
|
-
"""
|
|
1223
|
-
inet_aton(string) -> bytes giving packed 32-bit IP representation
|
|
1224
|
-
|
|
1225
|
-
Convert an IP address in string format (123.45.67.89) to the 32-bit packed
|
|
1226
|
-
binary format used in low-level network functions.
|
|
1227
|
-
"""
|
|
1214
|
+
"""Convert an IP address in string format (123.45.67.89) to the 32-bit packed binary format used in low-level network functions."""
|
|
1228
1215
|
...
|
|
1229
1216
|
def inet_ntoa(packed_ip: ReadableBuffer, /) -> str:
|
|
1230
|
-
"""
|
|
1231
|
-
inet_ntoa(packed_ip) -> ip_address_string
|
|
1232
|
-
|
|
1233
|
-
Convert an IP address from 32-bit packed binary format to string format
|
|
1234
|
-
"""
|
|
1217
|
+
"""Convert an IP address from 32-bit packed binary format to string format."""
|
|
1235
1218
|
...
|
|
1236
1219
|
def inet_pton(address_family: int, ip_string: str, /) -> bytes:
|
|
1237
1220
|
"""
|
|
@@ -1321,11 +1304,7 @@ def if_nameindex() -> list[tuple[int, str]]:
|
|
|
1321
1304
|
"""
|
|
1322
1305
|
...
|
|
1323
1306
|
def if_nametoindex(oname: str, /) -> int:
|
|
1324
|
-
"""
|
|
1325
|
-
if_nametoindex(if_name)
|
|
1326
|
-
|
|
1327
|
-
Returns the interface index corresponding to the interface name if_name.
|
|
1328
|
-
"""
|
|
1307
|
+
"""Returns the interface index corresponding to the interface name if_name."""
|
|
1329
1308
|
...
|
|
1330
1309
|
def if_indextoname(index: int, /) -> str:
|
|
1331
1310
|
"""
|
|
@@ -239,10 +239,15 @@ if sys.version_info >= (3, 12):
|
|
|
239
239
|
autocommit: bool = ...,
|
|
240
240
|
) -> Connection:
|
|
241
241
|
"""
|
|
242
|
-
|
|
242
|
+
Open a connection to the SQLite database file 'database'.
|
|
243
243
|
|
|
244
|
-
You can use ":memory:" to open a database connection to a database that
|
|
245
|
-
in RAM instead of on disk.
|
|
244
|
+
You can use ":memory:" to open a database connection to a database that
|
|
245
|
+
resides in RAM instead of on disk.
|
|
246
|
+
|
|
247
|
+
Note: Passing more than 1 positional argument to _sqlite3.connect() is
|
|
248
|
+
deprecated. Parameters 'timeout', 'detect_types', 'isolation_level',
|
|
249
|
+
'check_same_thread', 'factory', 'cached_statements' and 'uri' will
|
|
250
|
+
become keyword-only parameters in Python 3.15.
|
|
246
251
|
"""
|
|
247
252
|
...
|
|
248
253
|
@overload
|
|
@@ -259,10 +264,15 @@ if sys.version_info >= (3, 12):
|
|
|
259
264
|
autocommit: bool = ...,
|
|
260
265
|
) -> _ConnectionT:
|
|
261
266
|
"""
|
|
262
|
-
|
|
267
|
+
Open a connection to the SQLite database file 'database'.
|
|
263
268
|
|
|
264
|
-
You can use ":memory:" to open a database connection to a database that
|
|
265
|
-
in RAM instead of on disk.
|
|
269
|
+
You can use ":memory:" to open a database connection to a database that
|
|
270
|
+
resides in RAM instead of on disk.
|
|
271
|
+
|
|
272
|
+
Note: Passing more than 1 positional argument to _sqlite3.connect() is
|
|
273
|
+
deprecated. Parameters 'timeout', 'detect_types', 'isolation_level',
|
|
274
|
+
'check_same_thread', 'factory', 'cached_statements' and 'uri' will
|
|
275
|
+
become keyword-only parameters in Python 3.15.
|
|
266
276
|
"""
|
|
267
277
|
...
|
|
268
278
|
@overload
|
|
@@ -279,10 +289,15 @@ if sys.version_info >= (3, 12):
|
|
|
279
289
|
autocommit: bool = ...,
|
|
280
290
|
) -> _ConnectionT:
|
|
281
291
|
"""
|
|
282
|
-
|
|
292
|
+
Open a connection to the SQLite database file 'database'.
|
|
283
293
|
|
|
284
|
-
You can use ":memory:" to open a database connection to a database that
|
|
285
|
-
in RAM instead of on disk.
|
|
294
|
+
You can use ":memory:" to open a database connection to a database that
|
|
295
|
+
resides in RAM instead of on disk.
|
|
296
|
+
|
|
297
|
+
Note: Passing more than 1 positional argument to _sqlite3.connect() is
|
|
298
|
+
deprecated. Parameters 'timeout', 'detect_types', 'isolation_level',
|
|
299
|
+
'check_same_thread', 'factory', 'cached_statements' and 'uri' will
|
|
300
|
+
become keyword-only parameters in Python 3.15.
|
|
286
301
|
"""
|
|
287
302
|
...
|
|
288
303
|
|
|
@@ -31,18 +31,29 @@ S_IROTH: read by others
|
|
|
31
31
|
S_IWOTH: write by others
|
|
32
32
|
S_IXOTH: execute by others
|
|
33
33
|
|
|
34
|
+
UF_SETTABLE: mask of owner changable flags
|
|
34
35
|
UF_NODUMP: do not dump file
|
|
35
36
|
UF_IMMUTABLE: file may not be changed
|
|
36
37
|
UF_APPEND: file may only be appended to
|
|
37
38
|
UF_OPAQUE: directory is opaque when viewed through a union stack
|
|
38
39
|
UF_NOUNLINK: file may not be renamed or deleted
|
|
39
|
-
UF_COMPRESSED:
|
|
40
|
-
|
|
40
|
+
UF_COMPRESSED: macOS: file is hfs-compressed
|
|
41
|
+
UF_TRACKED: used for dealing with document IDs
|
|
42
|
+
UF_DATAVAULT: entitlement required for reading and writing
|
|
43
|
+
UF_HIDDEN: macOS: file should not be displayed
|
|
44
|
+
SF_SETTABLE: mask of super user changeable flags
|
|
41
45
|
SF_ARCHIVED: file may be archived
|
|
42
46
|
SF_IMMUTABLE: file may not be changed
|
|
43
47
|
SF_APPEND: file may only be appended to
|
|
48
|
+
SF_RESTRICTED: entitlement required for writing
|
|
44
49
|
SF_NOUNLINK: file may not be renamed or deleted
|
|
45
50
|
SF_SNAPSHOT: file is a snapshot file
|
|
51
|
+
SF_FIRMLINK: file is a firmlink
|
|
52
|
+
SF_DATALESS: file is a dataless object
|
|
53
|
+
|
|
54
|
+
On macOS:
|
|
55
|
+
SF_SUPPORTED: mask of super user supported flags
|
|
56
|
+
SF_SYNTHETIC: mask of read-only synthetic flags
|
|
46
57
|
|
|
47
58
|
ST_MODE
|
|
48
59
|
ST_INO
|
|
@@ -18,8 +18,6 @@ error = RuntimeError
|
|
|
18
18
|
|
|
19
19
|
def _count() -> int:
|
|
20
20
|
"""
|
|
21
|
-
_count() -> integer
|
|
22
|
-
|
|
23
21
|
Return the number of currently running Python threads, excluding
|
|
24
22
|
the main thread. The returned number comprises all threads created
|
|
25
23
|
through `start_new_thread()` as well as `threading.Thread`, and not
|
|
@@ -45,9 +43,6 @@ class LockType:
|
|
|
45
43
|
"""
|
|
46
44
|
def acquire(self, blocking: bool = True, timeout: float = -1) -> bool:
|
|
47
45
|
"""
|
|
48
|
-
acquire(blocking=True, timeout=-1) -> bool
|
|
49
|
-
(acquire_lock() is an obsolete synonym)
|
|
50
|
-
|
|
51
46
|
Lock the lock. Without argument, this blocks if the lock is already
|
|
52
47
|
locked (even by the same thread), waiting for another thread to release
|
|
53
48
|
the lock, and return True once the lock is acquired.
|
|
@@ -58,77 +53,30 @@ class LockType:
|
|
|
58
53
|
...
|
|
59
54
|
def release(self) -> None:
|
|
60
55
|
"""
|
|
61
|
-
release()
|
|
62
|
-
(release_lock() is an obsolete synonym)
|
|
63
|
-
|
|
64
56
|
Release the lock, allowing another thread that is blocked waiting for
|
|
65
57
|
the lock to acquire the lock. The lock must be in the locked state,
|
|
66
58
|
but it needn't be locked by the same thread that unlocks it.
|
|
67
59
|
"""
|
|
68
60
|
...
|
|
69
61
|
def locked(self) -> bool:
|
|
70
|
-
"""
|
|
71
|
-
locked() -> bool
|
|
72
|
-
(locked_lock() is an obsolete synonym)
|
|
73
|
-
|
|
74
|
-
Return whether the lock is in the locked state.
|
|
75
|
-
"""
|
|
62
|
+
"""Return whether the lock is in the locked state."""
|
|
76
63
|
...
|
|
77
64
|
def acquire_lock(self, blocking: bool = True, timeout: float = -1) -> bool:
|
|
78
|
-
"""
|
|
79
|
-
acquire(blocking=True, timeout=-1) -> bool
|
|
80
|
-
(acquire_lock() is an obsolete synonym)
|
|
81
|
-
|
|
82
|
-
Lock the lock. Without argument, this blocks if the lock is already
|
|
83
|
-
locked (even by the same thread), waiting for another thread to release
|
|
84
|
-
the lock, and return True once the lock is acquired.
|
|
85
|
-
With an argument, this will only block if the argument is true,
|
|
86
|
-
and the return value reflects whether the lock is acquired.
|
|
87
|
-
The blocking operation is interruptible.
|
|
88
|
-
"""
|
|
65
|
+
"""An obsolete synonym of acquire()."""
|
|
89
66
|
...
|
|
90
67
|
def release_lock(self) -> None:
|
|
91
|
-
"""
|
|
92
|
-
release()
|
|
93
|
-
(release_lock() is an obsolete synonym)
|
|
94
|
-
|
|
95
|
-
Release the lock, allowing another thread that is blocked waiting for
|
|
96
|
-
the lock to acquire the lock. The lock must be in the locked state,
|
|
97
|
-
but it needn't be locked by the same thread that unlocks it.
|
|
98
|
-
"""
|
|
68
|
+
"""An obsolete synonym of release()."""
|
|
99
69
|
...
|
|
100
70
|
def locked_lock(self) -> bool:
|
|
101
|
-
"""
|
|
102
|
-
locked() -> bool
|
|
103
|
-
(locked_lock() is an obsolete synonym)
|
|
104
|
-
|
|
105
|
-
Return whether the lock is in the locked state.
|
|
106
|
-
"""
|
|
71
|
+
"""An obsolete synonym of locked()."""
|
|
107
72
|
...
|
|
108
73
|
def __enter__(self) -> bool:
|
|
109
|
-
"""
|
|
110
|
-
acquire(blocking=True, timeout=-1) -> bool
|
|
111
|
-
(acquire_lock() is an obsolete synonym)
|
|
112
|
-
|
|
113
|
-
Lock the lock. Without argument, this blocks if the lock is already
|
|
114
|
-
locked (even by the same thread), waiting for another thread to release
|
|
115
|
-
the lock, and return True once the lock is acquired.
|
|
116
|
-
With an argument, this will only block if the argument is true,
|
|
117
|
-
and the return value reflects whether the lock is acquired.
|
|
118
|
-
The blocking operation is interruptible.
|
|
119
|
-
"""
|
|
74
|
+
"""Lock the lock."""
|
|
120
75
|
...
|
|
121
76
|
def __exit__(
|
|
122
77
|
self, type: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None
|
|
123
78
|
) -> None:
|
|
124
|
-
"""
|
|
125
|
-
release()
|
|
126
|
-
(release_lock() is an obsolete synonym)
|
|
127
|
-
|
|
128
|
-
Release the lock, allowing another thread that is blocked waiting for
|
|
129
|
-
the lock to acquire the lock. The lock must be in the locked state,
|
|
130
|
-
but it needn't be locked by the same thread that unlocks it.
|
|
131
|
-
"""
|
|
79
|
+
"""Release the lock."""
|
|
132
80
|
...
|
|
133
81
|
|
|
134
82
|
if sys.version_info >= (3, 13):
|
|
@@ -142,43 +90,51 @@ if sys.version_info >= (3, 13):
|
|
|
142
90
|
|
|
143
91
|
def start_joinable_thread(
|
|
144
92
|
function: Callable[[], object], handle: _ThreadHandle | None = None, daemon: bool = True
|
|
145
|
-
) -> _ThreadHandle:
|
|
93
|
+
) -> _ThreadHandle:
|
|
94
|
+
"""
|
|
95
|
+
*For internal use only*: start a new thread.
|
|
96
|
+
|
|
97
|
+
Like start_new_thread(), this starts a new thread calling the given function.
|
|
98
|
+
Unlike start_new_thread(), this returns a handle object with methods to join
|
|
99
|
+
or detach the given thread.
|
|
100
|
+
This function is not for third-party code, please use the
|
|
101
|
+
`threading` module instead. During finalization the runtime will not wait for
|
|
102
|
+
the thread to exit if daemon is True. If handle is provided it must be a
|
|
103
|
+
newly created thread._ThreadHandle instance.
|
|
104
|
+
"""
|
|
105
|
+
...
|
|
146
106
|
lock = LockType
|
|
147
107
|
|
|
148
108
|
@overload
|
|
149
109
|
def start_new_thread(function: Callable[[Unpack[_Ts]], object], args: tuple[Unpack[_Ts]], /) -> int:
|
|
150
110
|
"""
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
printed unless the exception is SystemExit.
|
|
111
|
+
Start a new thread and return its identifier.
|
|
112
|
+
|
|
113
|
+
The thread will call the function with positional arguments from the
|
|
114
|
+
tuple args and keyword arguments taken from the optional dictionary
|
|
115
|
+
kwargs. The thread exits when the function returns; the return value
|
|
116
|
+
is ignored. The thread will also exit when the function raises an
|
|
117
|
+
unhandled exception; a stack trace will be printed unless the exception
|
|
118
|
+
is SystemExit.
|
|
160
119
|
"""
|
|
161
120
|
...
|
|
162
121
|
@overload
|
|
163
122
|
def start_new_thread(function: Callable[..., object], args: tuple[Any, ...], kwargs: dict[str, Any], /) -> int:
|
|
164
123
|
"""
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
printed unless the exception is SystemExit.
|
|
124
|
+
Start a new thread and return its identifier.
|
|
125
|
+
|
|
126
|
+
The thread will call the function with positional arguments from the
|
|
127
|
+
tuple args and keyword arguments taken from the optional dictionary
|
|
128
|
+
kwargs. The thread exits when the function returns; the return value
|
|
129
|
+
is ignored. The thread will also exit when the function raises an
|
|
130
|
+
unhandled exception; a stack trace will be printed unless the exception
|
|
131
|
+
is SystemExit.
|
|
174
132
|
"""
|
|
175
133
|
...
|
|
176
134
|
|
|
177
135
|
if sys.version_info >= (3, 10):
|
|
178
136
|
def interrupt_main(signum: signal.Signals = ..., /) -> None:
|
|
179
137
|
"""
|
|
180
|
-
interrupt_main(signum=signal.SIGINT, /)
|
|
181
|
-
|
|
182
138
|
Simulate the arrival of the given signal in the main thread,
|
|
183
139
|
where the corresponding signal handler will be executed.
|
|
184
140
|
If *signum* is omitted, SIGINT is assumed.
|
|
@@ -200,26 +156,18 @@ else:
|
|
|
200
156
|
|
|
201
157
|
def exit() -> NoReturn:
|
|
202
158
|
"""
|
|
203
|
-
exit()
|
|
204
|
-
(exit_thread() is an obsolete synonym)
|
|
205
|
-
|
|
206
159
|
This is synonymous to ``raise SystemExit''. It will cause the current
|
|
207
160
|
thread to exit silently unless the exception is caught.
|
|
208
161
|
"""
|
|
209
162
|
...
|
|
210
163
|
def allocate_lock() -> LockType:
|
|
211
164
|
"""
|
|
212
|
-
allocate_lock() -> lock object
|
|
213
|
-
(allocate() is an obsolete synonym)
|
|
214
|
-
|
|
215
165
|
Create a new lock object. See help(type(threading.Lock())) for
|
|
216
166
|
information about locks.
|
|
217
167
|
"""
|
|
218
168
|
...
|
|
219
169
|
def get_ident() -> int:
|
|
220
170
|
"""
|
|
221
|
-
get_ident() -> integer
|
|
222
|
-
|
|
223
171
|
Return a non-zero integer that uniquely identifies the current thread
|
|
224
172
|
amongst other threads that exist simultaneously.
|
|
225
173
|
This may be used to identify per-thread resources.
|
|
@@ -231,8 +179,6 @@ def get_ident() -> int:
|
|
|
231
179
|
...
|
|
232
180
|
def stack_size(size: int = 0, /) -> int:
|
|
233
181
|
"""
|
|
234
|
-
stack_size([size]) -> size
|
|
235
|
-
|
|
236
182
|
Return the thread stack size used when creating new threads. The
|
|
237
183
|
optional size argument specifies the stack size (in bytes) to be used
|
|
238
184
|
for subsequently created threads, and must be 0 (use platform or
|
|
@@ -256,8 +202,6 @@ TIMEOUT_MAX: float
|
|
|
256
202
|
|
|
257
203
|
def get_native_id() -> int:
|
|
258
204
|
"""
|
|
259
|
-
get_native_id() -> integer
|
|
260
|
-
|
|
261
205
|
Return a non-negative integer identifying the thread as reported
|
|
262
206
|
by the OS (kernel). This may be used to uniquely identify a
|
|
263
207
|
particular thread within a system.
|
|
@@ -295,8 +239,6 @@ _excepthook: Callable[[_ExceptHookArgs], Any]
|
|
|
295
239
|
if sys.version_info >= (3, 12):
|
|
296
240
|
def daemon_threads_allowed() -> bool:
|
|
297
241
|
"""
|
|
298
|
-
daemon_threads_allowed()
|
|
299
|
-
|
|
300
242
|
Return True if daemon threads are allowed in the current interpreter,
|
|
301
243
|
and False otherwise.
|
|
302
244
|
"""
|
|
@@ -44,7 +44,9 @@ class Future(Awaitable[_T], Iterable[_T]):
|
|
|
44
44
|
def _log_traceback(self, val: Literal[False]) -> None: ...
|
|
45
45
|
_asyncio_future_blocking: bool # is a part of duck-typing contract for `Future`
|
|
46
46
|
def __init__(self, *, loop: AbstractEventLoop | None = ...) -> None: ...
|
|
47
|
-
def __del__(self) -> None:
|
|
47
|
+
def __del__(self) -> None:
|
|
48
|
+
"""Called when the instance is about to be destroyed."""
|
|
49
|
+
...
|
|
48
50
|
def get_loop(self) -> AbstractEventLoop:
|
|
49
51
|
"""Return the event loop the Future is bound to."""
|
|
50
52
|
...
|