basedpyright 1.40.1 → 1.40.2
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.js +1 -1
- package/dist/typeshed-fallback/stdlib/_blake2.pyi +1 -1
- package/dist/typeshed-fallback/stdlib/_curses.pyi +81 -54
- package/dist/typeshed-fallback/stdlib/_curses_panel.pyi +8 -1
- package/dist/typeshed-fallback/stdlib/_decimal.pyi +9 -6
- package/dist/typeshed-fallback/stdlib/_interpqueues.pyi +24 -36
- package/dist/typeshed-fallback/stdlib/_interpreters.pyi +26 -71
- package/dist/typeshed-fallback/stdlib/_json.pyi +15 -11
- package/dist/typeshed-fallback/stdlib/_remote_debugging.pyi +355 -72
- package/dist/typeshed-fallback/stdlib/_socket.pyi +21 -21
- package/dist/typeshed-fallback/stdlib/_sqlite3.pyi +0 -15
- package/dist/typeshed-fallback/stdlib/_struct.pyi +39 -42
- package/dist/typeshed-fallback/stdlib/_thread.pyi +18 -14
- package/dist/typeshed-fallback/stdlib/array.pyi +8 -4
- package/dist/typeshed-fallback/stdlib/ast.pyi +9 -3
- package/dist/typeshed-fallback/stdlib/binascii.pyi +113 -10
- package/dist/typeshed-fallback/stdlib/builtins.pyi +260 -43
- package/dist/typeshed-fallback/stdlib/collections/__init__.pyi +12 -4
- package/dist/typeshed-fallback/stdlib/dataclasses.pyi +3 -1
- package/dist/typeshed-fallback/stdlib/datetime.pyi +93 -25
- package/dist/typeshed-fallback/stdlib/decimal.pyi +272 -208
- package/dist/typeshed-fallback/stdlib/faulthandler.pyi +29 -4
- package/dist/typeshed-fallback/stdlib/fcntl.pyi +6 -12
- package/dist/typeshed-fallback/stdlib/importlib/metadata/__init__.pyi +2 -0
- package/dist/typeshed-fallback/stdlib/json/encoder.pyi +2 -10
- package/dist/typeshed-fallback/stdlib/marshal.pyi +33 -2
- package/dist/typeshed-fallback/stdlib/math/__init__.pyi +15 -7
- package/dist/typeshed-fallback/stdlib/math/integer.pyi +43 -8
- package/dist/typeshed-fallback/stdlib/mmap.pyi +1 -1
- package/dist/typeshed-fallback/stdlib/os/__init__.pyi +60 -4
- package/dist/typeshed-fallback/stdlib/posixpath.pyi +14 -2
- package/dist/typeshed-fallback/stdlib/profiling/__init__.pyi +3 -3
- package/dist/typeshed-fallback/stdlib/profiling/sampling/__init__.pyi +17 -17
- package/dist/typeshed-fallback/stdlib/profiling/sampling/collector.pyi +25 -25
- package/dist/typeshed-fallback/stdlib/profiling/sampling/gecko_collector.pyi +111 -111
- package/dist/typeshed-fallback/stdlib/profiling/sampling/heatmap_collector.pyi +24 -24
- package/dist/typeshed-fallback/stdlib/profiling/sampling/jsonl_collector.pyi +15 -15
- package/dist/typeshed-fallback/stdlib/profiling/sampling/pstats_collector.pyi +17 -17
- package/dist/typeshed-fallback/stdlib/profiling/sampling/stack_collector.pyi +39 -39
- package/dist/typeshed-fallback/stdlib/profiling/sampling/string_table.pyi +5 -5
- package/dist/typeshed-fallback/stdlib/profiling/tracing.pyi +9 -9
- package/dist/typeshed-fallback/stdlib/pyexpat/__init__.pyi +24 -18
- package/dist/typeshed-fallback/stdlib/re.pyi +18 -3
- package/dist/typeshed-fallback/stdlib/select.pyi +2 -2
- package/dist/typeshed-fallback/stdlib/signal.pyi +1 -1
- package/dist/typeshed-fallback/stdlib/sqlite3/__init__.pyi +28 -5
- package/dist/typeshed-fallback/stdlib/sys/__init__.pyi +42 -4
- package/dist/typeshed-fallback/stdlib/types.pyi +44 -14
- package/dist/typeshed-fallback/stdlib/unicodedata.pyi +27 -9
- package/dist/typeshed-fallback/stdlib/urllib/parse.pyi +132 -6
- package/dist/typeshed-fallback/stdlib/winreg.pyi +5 -0
- package/dist/typeshed-fallback/stdlib/xml/utils.pyi +2 -2
- package/dist/typeshed-fallback/stdlib/zlib.pyi +34 -2
- package/package.json +1 -1
|
@@ -74,22 +74,26 @@ class make_scanner:
|
|
|
74
74
|
...
|
|
75
75
|
|
|
76
76
|
def encode_basestring(s: str, /) -> str:
|
|
77
|
-
"""
|
|
78
|
-
encode_basestring(string) -> string
|
|
79
|
-
|
|
80
|
-
Return a JSON representation of a Python string
|
|
81
|
-
"""
|
|
77
|
+
"""Return a JSON representation of a Python string"""
|
|
82
78
|
...
|
|
83
79
|
def encode_basestring_ascii(s: str, /) -> str:
|
|
84
|
-
"""
|
|
85
|
-
encode_basestring_ascii(string) -> string
|
|
86
|
-
|
|
87
|
-
Return an ASCII-only JSON representation of a Python string
|
|
88
|
-
"""
|
|
80
|
+
"""Return an ASCII-only JSON representation of a Python string"""
|
|
89
81
|
...
|
|
90
82
|
|
|
91
83
|
if sys.version_info >= (3, 15):
|
|
92
|
-
def scanstring(pystr: str, end: int, strict: bool = True, /) -> tuple[str, int]:
|
|
84
|
+
def scanstring(pystr: str, end: int, strict: bool = True, /) -> tuple[str, int]:
|
|
85
|
+
"""
|
|
86
|
+
Scan the string s for a JSON string.
|
|
87
|
+
|
|
88
|
+
End is the index of the character in s after the quote that started the
|
|
89
|
+
JSON string. Unescapes all valid JSON string escape sequences and raises
|
|
90
|
+
ValueError on attempt to decode an invalid string. If strict is False
|
|
91
|
+
then literal control characters are allowed in the string.
|
|
92
|
+
|
|
93
|
+
Returns a tuple of the decoded string and the index of the character in
|
|
94
|
+
s after the end quote.
|
|
95
|
+
"""
|
|
96
|
+
...
|
|
93
97
|
|
|
94
98
|
else:
|
|
95
99
|
def scanstring(string: str, end: int, strict: bool = True) -> tuple[str, int]:
|
|
@@ -17,15 +17,24 @@ THREAD_STATUS_UNKNOWN: Final[int]
|
|
|
17
17
|
|
|
18
18
|
@final
|
|
19
19
|
class LocationInfo(structseq[int], tuple[int, int, int, int]):
|
|
20
|
+
"""Source location information: (lineno, end_lineno, col_offset, end_col_offset)"""
|
|
20
21
|
__match_args__: Final = ("lineno", "end_lineno", "col_offset", "end_col_offset")
|
|
21
22
|
@property
|
|
22
|
-
def lineno(self) -> int:
|
|
23
|
+
def lineno(self) -> int:
|
|
24
|
+
"""Line number"""
|
|
25
|
+
...
|
|
23
26
|
@property
|
|
24
|
-
def end_lineno(self) -> int:
|
|
27
|
+
def end_lineno(self) -> int:
|
|
28
|
+
"""End line number"""
|
|
29
|
+
...
|
|
25
30
|
@property
|
|
26
|
-
def col_offset(self) -> int:
|
|
31
|
+
def col_offset(self) -> int:
|
|
32
|
+
"""Column offset"""
|
|
33
|
+
...
|
|
27
34
|
@property
|
|
28
|
-
def end_col_offset(self) -> int:
|
|
35
|
+
def end_col_offset(self) -> int:
|
|
36
|
+
"""End column offset"""
|
|
37
|
+
...
|
|
29
38
|
|
|
30
39
|
@final
|
|
31
40
|
class FrameInfo(structseq[object], tuple[str, _Location, str, int | None]):
|
|
@@ -36,13 +45,17 @@ class FrameInfo(structseq[object], tuple[str, _Location, str, int | None]):
|
|
|
36
45
|
"""Source code filename"""
|
|
37
46
|
...
|
|
38
47
|
@property
|
|
39
|
-
def location(self) -> _Location:
|
|
48
|
+
def location(self) -> _Location:
|
|
49
|
+
"""LocationInfo structseq or None for synthetic frames"""
|
|
50
|
+
...
|
|
40
51
|
@property
|
|
41
52
|
def funcname(self) -> str:
|
|
42
53
|
"""Function name"""
|
|
43
54
|
...
|
|
44
55
|
@property
|
|
45
|
-
def opcode(self) -> int | None:
|
|
56
|
+
def opcode(self) -> int | None:
|
|
57
|
+
"""Opcode being executed (None if not gathered)"""
|
|
58
|
+
...
|
|
46
59
|
|
|
47
60
|
@final
|
|
48
61
|
class CoroInfo(structseq[object], tuple[list[_Frame], int | str]):
|
|
@@ -87,7 +100,9 @@ class ThreadInfo(structseq[object], tuple[int, int, list[_Frame]]):
|
|
|
87
100
|
"""Thread ID"""
|
|
88
101
|
...
|
|
89
102
|
@property
|
|
90
|
-
def status(self) -> int:
|
|
103
|
+
def status(self) -> int:
|
|
104
|
+
"""Thread status (flags: HAS_GIL, ON_CPU, UNKNOWN or legacy enum)"""
|
|
105
|
+
...
|
|
91
106
|
@property
|
|
92
107
|
def frame_info(self) -> list[_Frame]:
|
|
93
108
|
"""Frame information"""
|
|
@@ -95,11 +110,16 @@ class ThreadInfo(structseq[object], tuple[int, int, list[_Frame]]):
|
|
|
95
110
|
|
|
96
111
|
@final
|
|
97
112
|
class InterpreterInfo(structseq[object], tuple[int, list[ThreadInfo]]):
|
|
113
|
+
"""Information about an interpreter"""
|
|
98
114
|
__match_args__: Final = ("interpreter_id", "threads")
|
|
99
115
|
@property
|
|
100
|
-
def interpreter_id(self) -> int:
|
|
116
|
+
def interpreter_id(self) -> int:
|
|
117
|
+
"""Interpreter ID"""
|
|
118
|
+
...
|
|
101
119
|
@property
|
|
102
|
-
def threads(self) -> list[ThreadInfo]:
|
|
120
|
+
def threads(self) -> list[ThreadInfo]:
|
|
121
|
+
"""List of threads in this interpreter"""
|
|
122
|
+
...
|
|
103
123
|
|
|
104
124
|
@final
|
|
105
125
|
class AwaitedInfo(structseq[object], tuple[int, list[TaskInfo]]):
|
|
@@ -116,6 +136,7 @@ class AwaitedInfo(structseq[object], tuple[int, list[TaskInfo]]):
|
|
|
116
136
|
|
|
117
137
|
@final
|
|
118
138
|
class GCStatsInfo(structseq[object], tuple[int, int, int, int, int, int, int, int, int, float]):
|
|
139
|
+
"""Information about a garbage collector stats sample"""
|
|
119
140
|
__match_args__: Final = (
|
|
120
141
|
"gen",
|
|
121
142
|
"iid",
|
|
@@ -129,25 +150,45 @@ class GCStatsInfo(structseq[object], tuple[int, int, int, int, int, int, int, in
|
|
|
129
150
|
"duration",
|
|
130
151
|
)
|
|
131
152
|
@property
|
|
132
|
-
def gen(self) -> int:
|
|
153
|
+
def gen(self) -> int:
|
|
154
|
+
"""GC generation number"""
|
|
155
|
+
...
|
|
133
156
|
@property
|
|
134
|
-
def iid(self) -> int:
|
|
157
|
+
def iid(self) -> int:
|
|
158
|
+
"""Interpreter ID"""
|
|
159
|
+
...
|
|
135
160
|
@property
|
|
136
|
-
def ts_start(self) -> int:
|
|
161
|
+
def ts_start(self) -> int:
|
|
162
|
+
"""Raw timestamp at collection start"""
|
|
163
|
+
...
|
|
137
164
|
@property
|
|
138
|
-
def ts_stop(self) -> int:
|
|
165
|
+
def ts_stop(self) -> int:
|
|
166
|
+
"""Raw timestamp at collection stop"""
|
|
167
|
+
...
|
|
139
168
|
@property
|
|
140
|
-
def collections(self) -> int:
|
|
169
|
+
def collections(self) -> int:
|
|
170
|
+
"""Total number of collections"""
|
|
171
|
+
...
|
|
141
172
|
@property
|
|
142
|
-
def collected(self) -> int:
|
|
173
|
+
def collected(self) -> int:
|
|
174
|
+
"""Total number of collected objects"""
|
|
175
|
+
...
|
|
143
176
|
@property
|
|
144
|
-
def uncollectable(self) -> int:
|
|
177
|
+
def uncollectable(self) -> int:
|
|
178
|
+
"""Total number of uncollectable objects"""
|
|
179
|
+
...
|
|
145
180
|
@property
|
|
146
|
-
def candidates(self) -> int:
|
|
181
|
+
def candidates(self) -> int:
|
|
182
|
+
"""Total objects considered and traversed"""
|
|
183
|
+
...
|
|
147
184
|
@property
|
|
148
|
-
def heap_size(self) -> int:
|
|
185
|
+
def heap_size(self) -> int:
|
|
186
|
+
"""Number of live objects"""
|
|
187
|
+
...
|
|
149
188
|
@property
|
|
150
|
-
def duration(self) -> float:
|
|
189
|
+
def duration(self) -> float:
|
|
190
|
+
"""Total collection time, in seconds"""
|
|
191
|
+
...
|
|
151
192
|
|
|
152
193
|
@final
|
|
153
194
|
class RemoteUnwinder:
|
|
@@ -169,56 +210,77 @@ class RemoteUnwinder:
|
|
|
169
210
|
) -> None: ...
|
|
170
211
|
def get_stack_trace(self) -> list[InterpreterInfo]:
|
|
171
212
|
"""
|
|
172
|
-
Returns
|
|
213
|
+
Returns stack traces for all interpreters and threads in process.
|
|
173
214
|
|
|
174
|
-
Each element in the returned list is a tuple of (
|
|
175
|
-
|
|
176
|
-
-
|
|
177
|
-
|
|
215
|
+
Each element in the returned list is a tuple of (interpreter_id,
|
|
216
|
+
thread_list), where:
|
|
217
|
+
- interpreter_id is the interpreter identifier
|
|
218
|
+
- thread_list is a list of tuples (thread_id, frame_list) for
|
|
219
|
+
threads in that interpreter
|
|
220
|
+
- thread_id is the OS thread identifier
|
|
221
|
+
- frame_list is a list of tuples (function_name, filename,
|
|
222
|
+
line_number) representing the Python stack frames for that
|
|
223
|
+
thread, ordered from most recent to oldest
|
|
178
224
|
|
|
179
225
|
The threads returned depend on the initialization parameters:
|
|
180
|
-
- If only_active_thread was True: returns only the thread holding
|
|
181
|
-
|
|
182
|
-
-
|
|
226
|
+
- If only_active_thread was True: returns only the thread holding
|
|
227
|
+
the GIL across all interpreters
|
|
228
|
+
- If all_threads was True: returns all threads across all
|
|
229
|
+
interpreters
|
|
230
|
+
- Otherwise: returns only the main thread of each interpreter
|
|
183
231
|
|
|
184
232
|
Example:
|
|
185
233
|
[
|
|
186
|
-
(
|
|
187
|
-
(
|
|
188
|
-
|
|
189
|
-
|
|
234
|
+
(0, [ # Main interpreter
|
|
235
|
+
(1234, [
|
|
236
|
+
('process_data', 'worker.py', 127),
|
|
237
|
+
('run_worker', 'worker.py', 45),
|
|
238
|
+
('main', 'app.py', 23)
|
|
239
|
+
]),
|
|
240
|
+
(1235, [
|
|
241
|
+
('handle_request', 'server.py', 89),
|
|
242
|
+
('serve_forever', 'server.py', 52)
|
|
243
|
+
])
|
|
190
244
|
]),
|
|
191
|
-
(
|
|
192
|
-
(
|
|
193
|
-
|
|
245
|
+
(1, [ # Sub-interpreter
|
|
246
|
+
(1236, [
|
|
247
|
+
('sub_worker', 'sub.py', 15)
|
|
248
|
+
])
|
|
194
249
|
])
|
|
195
250
|
]
|
|
196
251
|
|
|
197
252
|
Raises:
|
|
198
|
-
RuntimeError: If there is an error copying memory from the
|
|
253
|
+
RuntimeError: If there is an error copying memory from the
|
|
254
|
+
target process
|
|
199
255
|
OSError: If there is an error accessing the target process
|
|
200
256
|
PermissionError: If access to the target process is denied
|
|
201
|
-
UnicodeDecodeError: If there is an error decoding strings from
|
|
257
|
+
UnicodeDecodeError: If there is an error decoding strings from
|
|
258
|
+
the target process
|
|
202
259
|
"""
|
|
203
260
|
...
|
|
204
261
|
def get_all_awaited_by(self) -> list[AwaitedInfo]:
|
|
205
262
|
"""
|
|
206
263
|
Get all tasks and their awaited_by relationships from the remote process.
|
|
207
264
|
|
|
208
|
-
This provides a tree structure showing which tasks are waiting for
|
|
265
|
+
This provides a tree structure showing which tasks are waiting for
|
|
266
|
+
other tasks.
|
|
209
267
|
|
|
210
268
|
For each task, returns:
|
|
211
|
-
1. The call stack frames leading to where the task is currently
|
|
269
|
+
1. The call stack frames leading to where the task is currently
|
|
270
|
+
executing
|
|
212
271
|
2. The name of the task
|
|
213
|
-
3. A list of tasks that this task is waiting for, with their own
|
|
272
|
+
3. A list of tasks that this task is waiting for, with their own
|
|
273
|
+
frames/names/etc
|
|
214
274
|
|
|
215
275
|
Returns a list of [frames, task_name, subtasks] where:
|
|
216
|
-
- frames: List of (func_name, filename, lineno) showing the call
|
|
276
|
+
- frames: List of (func_name, filename, lineno) showing the call
|
|
277
|
+
stack
|
|
217
278
|
- task_name: String identifier for the task
|
|
218
279
|
- subtasks: List of tasks being awaited by this task, in same format
|
|
219
280
|
|
|
220
281
|
Raises:
|
|
221
|
-
RuntimeError: If AsyncioDebug section is not available in the
|
|
282
|
+
RuntimeError: If AsyncioDebug section is not available in the
|
|
283
|
+
remote process
|
|
222
284
|
MemoryError: If memory allocation fails
|
|
223
285
|
OSError: If reading from the remote process fails
|
|
224
286
|
|
|
@@ -243,14 +305,16 @@ class RemoteUnwinder:
|
|
|
243
305
|
"""
|
|
244
306
|
Get the currently running async tasks and their dependency graphs from the remote process.
|
|
245
307
|
|
|
246
|
-
This returns information about running tasks and all tasks that are
|
|
247
|
-
forming a complete dependency graph for each
|
|
308
|
+
This returns information about running tasks and all tasks that are
|
|
309
|
+
waiting for them, forming a complete dependency graph for each
|
|
310
|
+
thread's active task.
|
|
248
311
|
|
|
249
|
-
For each thread with a running task, returns the running task plus
|
|
250
|
-
transitively depend on it (tasks waiting for the
|
|
251
|
-
those tasks, etc.).
|
|
312
|
+
For each thread with a running task, returns the running task plus
|
|
313
|
+
all tasks that transitively depend on it (tasks waiting for the
|
|
314
|
+
running task, tasks waiting for those tasks, etc.).
|
|
252
315
|
|
|
253
|
-
Returns a list of per-thread results, where each thread result
|
|
316
|
+
Returns a list of per-thread results, where each thread result
|
|
317
|
+
contains:
|
|
254
318
|
- Thread ID
|
|
255
319
|
- List of task information for the running task and all its waiters
|
|
256
320
|
|
|
@@ -261,11 +325,13 @@ class RemoteUnwinder:
|
|
|
261
325
|
- List of tasks waiting for this task (recursive structure)
|
|
262
326
|
|
|
263
327
|
Raises:
|
|
264
|
-
RuntimeError: If AsyncioDebug section is not available in the
|
|
328
|
+
RuntimeError: If AsyncioDebug section is not available in the
|
|
329
|
+
target process
|
|
265
330
|
MemoryError: If memory allocation fails
|
|
266
331
|
OSError: If reading from the remote process fails
|
|
267
332
|
|
|
268
|
-
Example output (similar structure to get_all_awaited_by but only for
|
|
333
|
+
Example output (similar structure to get_all_awaited_by but only for
|
|
334
|
+
running tasks):
|
|
269
335
|
[
|
|
270
336
|
(140234, [
|
|
271
337
|
(4345585712, 'main_task',
|
|
@@ -278,14 +344,111 @@ class RemoteUnwinder:
|
|
|
278
344
|
]
|
|
279
345
|
"""
|
|
280
346
|
...
|
|
281
|
-
def get_stats(self) -> _Stats:
|
|
282
|
-
|
|
283
|
-
|
|
347
|
+
def get_stats(self) -> _Stats:
|
|
348
|
+
"""
|
|
349
|
+
Get collected statistics about profiling performance.
|
|
350
|
+
|
|
351
|
+
Returns a dictionary containing statistics about cache performance,
|
|
352
|
+
memory reads, and other profiling metrics. Only available if the
|
|
353
|
+
RemoteUnwinder was created with stats=True.
|
|
354
|
+
|
|
355
|
+
Returns:
|
|
356
|
+
dict: A dictionary containing:
|
|
357
|
+
- total_samples: Total number of get_stack_trace calls
|
|
358
|
+
- frame_cache_hits: Full cache hits (entire stack unchanged)
|
|
359
|
+
- frame_cache_misses: Cache misses requiring full walk
|
|
360
|
+
- frame_cache_partial_hits: Partial hits (stopped at cached
|
|
361
|
+
frame)
|
|
362
|
+
- frames_read_from_cache: Total frames retrieved from cache
|
|
363
|
+
- frames_read_from_memory: Total frames read from remote
|
|
364
|
+
memory
|
|
365
|
+
- memory_reads: Total remote memory read operations
|
|
366
|
+
- memory_bytes_read: Total bytes read from remote memory
|
|
367
|
+
- code_object_cache_hits: Code object cache hits
|
|
368
|
+
- code_object_cache_misses: Code object cache misses
|
|
369
|
+
- stale_cache_invalidations: Times stale cache entries were
|
|
370
|
+
cleared
|
|
371
|
+
- batched_read_attempts: Batched remote-read attempts
|
|
372
|
+
- batched_read_successes: Attempts that read all requested
|
|
373
|
+
segments
|
|
374
|
+
- batched_read_misses: Attempts that fell back or partially
|
|
375
|
+
read
|
|
376
|
+
- batched_read_segments_requested: Segments requested by
|
|
377
|
+
batched reads
|
|
378
|
+
- batched_read_segments_completed: Segments completed by
|
|
379
|
+
batched reads
|
|
380
|
+
- frame_cache_hit_rate: Percentage of samples that hit the
|
|
381
|
+
cache
|
|
382
|
+
- code_object_cache_hit_rate: Percentage of code object
|
|
383
|
+
lookups that hit cache
|
|
384
|
+
- batched_read_success_rate: Percentage of batched reads
|
|
385
|
+
that completed all segments
|
|
386
|
+
- batched_read_segment_completion_rate: Percentage of
|
|
387
|
+
requested segments read by batched reads
|
|
388
|
+
|
|
389
|
+
Raises:
|
|
390
|
+
RuntimeError: If stats collection was not enabled (stats=False)
|
|
391
|
+
"""
|
|
392
|
+
...
|
|
393
|
+
def pause_threads(self) -> bool:
|
|
394
|
+
"""
|
|
395
|
+
Pause all threads in the target process.
|
|
396
|
+
|
|
397
|
+
This stops all threads in the target process to allow for consistent
|
|
398
|
+
memory reads during sampling. Must be paired with a call to
|
|
399
|
+
resume_threads().
|
|
400
|
+
|
|
401
|
+
Returns True if threads were successfully paused, False if they were
|
|
402
|
+
already paused.
|
|
403
|
+
|
|
404
|
+
Raises:
|
|
405
|
+
RuntimeError: If there is an error stopping the threads
|
|
406
|
+
"""
|
|
407
|
+
...
|
|
408
|
+
def resume_threads(self) -> bool:
|
|
409
|
+
"""
|
|
410
|
+
Resume all threads in the target process.
|
|
411
|
+
|
|
412
|
+
This resumes threads that were previously paused with
|
|
413
|
+
pause_threads().
|
|
414
|
+
|
|
415
|
+
Returns True if threads were successfully resumed, False if they
|
|
416
|
+
were not paused.
|
|
417
|
+
"""
|
|
418
|
+
...
|
|
284
419
|
|
|
285
420
|
@final
|
|
286
421
|
class GCMonitor:
|
|
422
|
+
"""GCMonitor(pid): Monitor GC events of a remote Python process."""
|
|
287
423
|
def __init__(self, pid: int, *, debug: bool = False) -> None: ...
|
|
288
|
-
def get_gc_stats(self, all_interpreters: bool = False) -> list[GCStatsInfo]:
|
|
424
|
+
def get_gc_stats(self, all_interpreters: bool = False) -> list[GCStatsInfo]:
|
|
425
|
+
"""
|
|
426
|
+
Get garbage collector statistics from external Python process.
|
|
427
|
+
|
|
428
|
+
all_interpreters
|
|
429
|
+
If True, return GC statistics from all interpreters.
|
|
430
|
+
If False, return only from main interpreter.
|
|
431
|
+
|
|
432
|
+
Returns a list of GCStatsInfo objects with GC statistics data.
|
|
433
|
+
|
|
434
|
+
Returns:
|
|
435
|
+
list of GCStatsInfo: A list of stats samples containing:
|
|
436
|
+
- gen: GC generation number.
|
|
437
|
+
- iid: Interpreter ID.
|
|
438
|
+
- ts_start: Raw timestamp at collection start.
|
|
439
|
+
- ts_stop: Raw timestamp at collection stop.
|
|
440
|
+
- collections: Total number of collections.
|
|
441
|
+
- collected: Total number of collected objects.
|
|
442
|
+
- uncollectable: Total number of uncollectable objects.
|
|
443
|
+
- candidates: Total objects considered and traversed.
|
|
444
|
+
- heap_size: number of live objects.
|
|
445
|
+
- duration: Total collection time, in seconds.
|
|
446
|
+
|
|
447
|
+
Raises:
|
|
448
|
+
RuntimeError: If the target process cannot be inspected or if
|
|
449
|
+
its debug offsets or GC stats layout are incompatible.
|
|
450
|
+
"""
|
|
451
|
+
...
|
|
289
452
|
|
|
290
453
|
@final
|
|
291
454
|
class BinaryWriter:
|
|
@@ -293,29 +456,149 @@ class BinaryWriter:
|
|
|
293
456
|
self, filename: StrOrBytesPath, sample_interval_us: int, start_time_us: int, *, compression: int = 0
|
|
294
457
|
) -> None: ...
|
|
295
458
|
@property
|
|
296
|
-
def total_samples(self) -> int:
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
def
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
459
|
+
def total_samples(self) -> int:
|
|
460
|
+
"""Total samples written"""
|
|
461
|
+
...
|
|
462
|
+
def write_sample(self, stack_frames: list[InterpreterInfo], timestamp_us: int) -> None:
|
|
463
|
+
"""
|
|
464
|
+
Write a sample to the binary file.
|
|
465
|
+
|
|
466
|
+
Arguments:
|
|
467
|
+
stack_frames: List of InterpreterInfo objects
|
|
468
|
+
timestamp_us: Current timestamp in microseconds (from
|
|
469
|
+
time.monotonic() * 1e6)
|
|
470
|
+
"""
|
|
471
|
+
...
|
|
472
|
+
def finalize(self) -> None:
|
|
473
|
+
"""
|
|
474
|
+
Finalize and close the binary file.
|
|
475
|
+
|
|
476
|
+
Writes string/frame tables, footer, and updates header.
|
|
477
|
+
"""
|
|
478
|
+
...
|
|
479
|
+
def close(self) -> None:
|
|
480
|
+
"""Close the writer without finalizing (discards data)."""
|
|
481
|
+
...
|
|
482
|
+
def __enter__(self) -> Self:
|
|
483
|
+
"""Enter context manager."""
|
|
484
|
+
...
|
|
485
|
+
def __exit__(self, exc_type: object = None, exc_val: object = None, exc_tb: object = None) -> bool:
|
|
486
|
+
"""Exit context manager, finalizing the file."""
|
|
487
|
+
...
|
|
488
|
+
def get_stats(self) -> _Stats:
|
|
489
|
+
"""
|
|
490
|
+
Get encoding statistics for the writer.
|
|
491
|
+
|
|
492
|
+
Returns a dict with encoding statistics including
|
|
493
|
+
repeat/full/suffix/pop-push record counts, frames written/saved, and
|
|
494
|
+
compression ratio.
|
|
495
|
+
"""
|
|
496
|
+
...
|
|
303
497
|
|
|
304
498
|
@final
|
|
305
499
|
class BinaryReader:
|
|
306
500
|
def __init__(self, filename: StrOrBytesPath) -> None: ...
|
|
307
501
|
@property
|
|
308
|
-
def sample_count(self) -> int:
|
|
502
|
+
def sample_count(self) -> int:
|
|
503
|
+
"""Number of samples in file"""
|
|
504
|
+
...
|
|
309
505
|
@property
|
|
310
|
-
def sample_interval_us(self) -> int:
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
def
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
506
|
+
def sample_interval_us(self) -> int:
|
|
507
|
+
"""Sample interval in microseconds"""
|
|
508
|
+
...
|
|
509
|
+
def replay(self, collector: object, progress_callback: Callable[[int, int], object] | None = None) -> int:
|
|
510
|
+
"""
|
|
511
|
+
Replay samples through a collector.
|
|
512
|
+
|
|
513
|
+
Arguments:
|
|
514
|
+
collector: Collector object with collect() method
|
|
515
|
+
progress_callback: Optional callable(current, total)
|
|
516
|
+
|
|
517
|
+
Returns:
|
|
518
|
+
Number of samples replayed
|
|
519
|
+
"""
|
|
520
|
+
...
|
|
521
|
+
def get_info(self) -> dict[str, object]:
|
|
522
|
+
"""
|
|
523
|
+
Get metadata about the binary file.
|
|
524
|
+
|
|
525
|
+
Returns:
|
|
526
|
+
Dict with file metadata
|
|
527
|
+
"""
|
|
528
|
+
...
|
|
529
|
+
def get_stats(self) -> _Stats:
|
|
530
|
+
"""
|
|
531
|
+
Get reconstruction statistics from replay.
|
|
532
|
+
|
|
533
|
+
Returns a dict with statistics about record types decoded and
|
|
534
|
+
samples reconstructed during replay.
|
|
535
|
+
"""
|
|
536
|
+
...
|
|
537
|
+
def close(self) -> None:
|
|
538
|
+
"""Close the reader and free resources."""
|
|
539
|
+
...
|
|
540
|
+
def __enter__(self) -> Self:
|
|
541
|
+
"""Enter context manager."""
|
|
542
|
+
...
|
|
543
|
+
def __exit__(self, exc_type: object = None, exc_val: object = None, exc_tb: object = None) -> bool:
|
|
544
|
+
"""Exit context manager, closing the file."""
|
|
545
|
+
...
|
|
546
|
+
|
|
547
|
+
def zstd_available() -> bool:
|
|
548
|
+
"""
|
|
549
|
+
Check if zstd compression is available.
|
|
550
|
+
|
|
551
|
+
Returns:
|
|
552
|
+
True if zstd available, False otherwise
|
|
553
|
+
"""
|
|
554
|
+
...
|
|
555
|
+
def get_child_pids(pid: int, *, recursive: bool = True) -> list[int]:
|
|
556
|
+
"""
|
|
557
|
+
Get all child process IDs of the given process.
|
|
558
|
+
|
|
559
|
+
pid
|
|
560
|
+
Process ID of the parent process
|
|
561
|
+
recursive
|
|
562
|
+
If True, return all descendants (children, grandchildren, etc.).
|
|
563
|
+
If False, return only direct children.
|
|
564
|
+
|
|
565
|
+
Returns a list of child process IDs. Returns an empty list if no
|
|
566
|
+
children are found.
|
|
567
|
+
|
|
568
|
+
This function provides a snapshot of child processes at a moment in
|
|
569
|
+
time. Child processes may exit or new ones may be created after the
|
|
570
|
+
list is returned.
|
|
571
|
+
|
|
572
|
+
Raises:
|
|
573
|
+
OSError: If unable to enumerate processes
|
|
574
|
+
NotImplementedError: If not supported on this platform
|
|
575
|
+
"""
|
|
576
|
+
...
|
|
577
|
+
def is_python_process(pid: int) -> bool:
|
|
578
|
+
"""Check if a process is a Python process."""
|
|
579
|
+
...
|
|
580
|
+
def get_gc_stats(pid: int, *, all_interpreters: bool = False) -> list[GCStatsInfo]:
|
|
581
|
+
"""
|
|
582
|
+
Get garbage collector statistics from external Python process.
|
|
583
|
+
|
|
584
|
+
all_interpreters
|
|
585
|
+
If True, return GC statistics from all interpreters.
|
|
586
|
+
If False, return only from main interpreter.
|
|
587
|
+
|
|
588
|
+
Returns:
|
|
589
|
+
list of GCStatsInfo: A list of stats samples containing:
|
|
590
|
+
- gen: GC generation number.
|
|
591
|
+
- iid: Interpreter ID.
|
|
592
|
+
- ts_start: Raw timestamp at collection start.
|
|
593
|
+
- ts_stop: Raw timestamp at collection stop.
|
|
594
|
+
- collections: Total number of collections.
|
|
595
|
+
- collected: Total number of collected objects.
|
|
596
|
+
- uncollectable: Total number of uncollectable objects.
|
|
597
|
+
- candidates: Total objects considered and traversed.
|
|
598
|
+
- duration: Total collection time, in seconds.
|
|
317
599
|
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
600
|
+
Raises:
|
|
601
|
+
RuntimeError: If the target process cannot be inspected or if its
|
|
602
|
+
debug offsets or GC stats layout are incompatible.
|
|
603
|
+
"""
|
|
604
|
+
...
|
|
@@ -1136,21 +1136,21 @@ class socket:
|
|
|
1136
1136
|
...
|
|
1137
1137
|
def send(self, data: ReadableBuffer, flags: int = 0, /) -> int:
|
|
1138
1138
|
"""
|
|
1139
|
-
|
|
1139
|
+
Send a data string to the socket.
|
|
1140
1140
|
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1141
|
+
For the optional flags argument, see the Unix manual.
|
|
1142
|
+
Return the number of bytes sent; this may be less than len(data) if
|
|
1143
|
+
the network is busy.
|
|
1144
1144
|
"""
|
|
1145
1145
|
...
|
|
1146
1146
|
def sendall(self, data: ReadableBuffer, flags: int = 0, /) -> None:
|
|
1147
1147
|
"""
|
|
1148
|
-
|
|
1148
|
+
Send a data string to the socket.
|
|
1149
1149
|
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1150
|
+
For the optional flags argument, see the Unix manual.
|
|
1151
|
+
This calls send() repeatedly until all data is sent.
|
|
1152
|
+
If an error occurs, it's impossible to tell how much data has been
|
|
1153
|
+
sent.
|
|
1154
1154
|
"""
|
|
1155
1155
|
...
|
|
1156
1156
|
|
|
@@ -1183,21 +1183,21 @@ class socket:
|
|
|
1183
1183
|
/,
|
|
1184
1184
|
) -> int:
|
|
1185
1185
|
"""
|
|
1186
|
-
|
|
1186
|
+
Send normal and ancillary data to the socket.
|
|
1187
1187
|
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1188
|
+
It gathering the non-ancillary data from a series of buffers
|
|
1189
|
+
and concatenating it into a single message.
|
|
1190
|
+
The buffers argument specifies the non-ancillary
|
|
1191
1191
|
data as an iterable of bytes-like objects (e.g. bytes objects).
|
|
1192
1192
|
The ancdata argument specifies the ancillary data (control messages)
|
|
1193
1193
|
as an iterable of zero or more tuples (cmsg_level, cmsg_type,
|
|
1194
|
-
cmsg_data), where cmsg_level and cmsg_type are integers specifying
|
|
1195
|
-
protocol level and protocol-specific type respectively, and
|
|
1196
|
-
is a bytes-like object holding the associated data. The
|
|
1197
|
-
argument defaults to 0 and has the same meaning as for send().
|
|
1198
|
-
address is supplied and not None, it sets a destination address
|
|
1199
|
-
the message. The return value is the number of bytes of
|
|
1200
|
-
data sent.
|
|
1194
|
+
cmsg_data), where cmsg_level and cmsg_type are integers specifying
|
|
1195
|
+
the protocol level and protocol-specific type respectively, and
|
|
1196
|
+
cmsg_data is a bytes-like object holding the associated data. The
|
|
1197
|
+
flags argument defaults to 0 and has the same meaning as for send().
|
|
1198
|
+
If address is supplied and not None, it sets a destination address
|
|
1199
|
+
for the message. The return value is the number of bytes of
|
|
1200
|
+
non-ancillary data sent.
|
|
1201
1201
|
"""
|
|
1202
1202
|
...
|
|
1203
1203
|
if sys.platform == "linux":
|
|
@@ -1404,7 +1404,7 @@ def setdefaulttimeout(timeout: float | None, /) -> None:
|
|
|
1404
1404
|
"""
|
|
1405
1405
|
setdefaulttimeout(timeout)
|
|
1406
1406
|
|
|
1407
|
-
Set the default timeout in seconds (
|
|
1407
|
+
Set the default timeout in seconds (real number) for new socket objects.
|
|
1408
1408
|
A value of None indicates that new socket objects have no timeout.
|
|
1409
1409
|
When the socket module is first imported, the default is None.
|
|
1410
1410
|
"""
|