Skip to content

Commit 64b1fd1

Browse files
committed
the kolektor
1 parent 639a552 commit 64b1fd1

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

Lib/profiling/sampling/binary_collector.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""Thin Python wrapper around C binary writer for profiling data."""
22

3+
import sys
34
import time
45

56
import _remote_debugging
@@ -61,6 +62,7 @@ def __init__(self, filename, sample_interval_usec, *, skip_idle=False,
6162
self.filename = filename
6263
self.sample_interval_usec = sample_interval_usec
6364
self.skip_idle = skip_idle
65+
self.running = True
6466

6567
compression_type = _resolve_compression(compression)
6668
start_time_us = int(time.monotonic() * 1_000_000)
@@ -81,7 +83,13 @@ def collect(self, stack_frames, timestamp_us=None):
8183
"""
8284
if timestamp_us is None:
8385
timestamp_us = int(time.monotonic() * 1_000_000)
84-
self._writer.write_sample(stack_frames, timestamp_us)
86+
try:
87+
self._writer.write_sample(stack_frames, timestamp_us)
88+
except OverflowError as e:
89+
self.running = False
90+
print(f"Warning: {e}; stopping early and keeping the data "
91+
"collected so far.",
92+
file=sys.stderr)
8593

8694
def collect_failed_sample(self):
8795
"""Record a failed sample attempt (no-op for binary format)."""

0 commit comments

Comments
 (0)