Skip to content

Commit 7b4bd69

Browse files
committed
preserve tracebacks, account for permission error, small fixes
1 parent 5b5ad2f commit 7b4bd69

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

Lib/profiling/sampling/errors.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33
class SamplingProfilerError(Exception):
44
"""Base exception for sampling profiler errors."""
55

6-
class SamplingPermissionError(SamplingProfilerError):
7-
def __init__(self):
8-
super().__init__(f"Insufficient permission to access process.")
9-
106
class SamplingUnknownProcessError(SamplingProfilerError):
117
def __init__(self, pid):
128
self.pid = pid

Lib/profiling/sampling/sample.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def __init__(self, pid, sample_interval_usec, all_threads, *, mode=PROFILING_MOD
3737
try:
3838
self.unwinder = self._new_unwinder(native, gc, opcodes, skip_non_matching_threads)
3939
except RuntimeError as err:
40-
raise SystemExit(err)
40+
raise SystemExit(err) from err
4141
# Track sample intervals and total sample count
4242
self.sample_intervals = deque(maxlen=100)
4343
self.total_samples = 0
@@ -278,6 +278,9 @@ def _is_process_running(pid):
278278
return True
279279
except ProcessLookupError:
280280
return False
281+
except PermissionError:
282+
# EPERM means process exists but we can't signal it
283+
return True
281284
elif sys.platform == "win32":
282285
try:
283286
_remote_debugging.RemoteUnwinder(pid)

0 commit comments

Comments
 (0)