Skip to content

Commit 2dfdc1c

Browse files
committed
fixup! Handle the process runs shorter than expected
1 parent e67e1fb commit 2dfdc1c

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

Lib/profile/sample.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,10 @@ def sample(self, collector, duration_sec=10):
5454
stack_frames = self.unwinder.get_stack_trace()
5555
collector.collect(stack_frames)
5656
except ProcessLookupError:
57+
duration_sec = current_time - start_time
5758
break
5859
except (RuntimeError, UnicodeDecodeError, MemoryError, OSError):
5960
errors += 1
60-
except ValueError as e:
61-
# Process is waiting to be reaped by the parent (us)
62-
if self._is_process_running():
63-
duration_sec = (
64-
current_time - start_time
65-
)
66-
break
67-
raise e from None
6861
except Exception as e:
6962
if not self._is_process_running():
7063
break
@@ -549,11 +542,11 @@ def _validate_collapsed_format_args(args, parser):
549542
args.outfile = f"collapsed.{args.pid}.txt"
550543

551544

552-
def wait_for_process_and_sample(process_pid, sort_value, args):
545+
def wait_for_process_and_sample(pid, sort_value, args):
553546
for attempt in range(MAX_STARTUP_ATTEMPTS):
554547
try:
555548
sample(
556-
process_pid,
549+
pid,
557550
sort=sort_value,
558551
sample_interval_usec=args.interval,
559552
duration_sec=args.duration,

0 commit comments

Comments
 (0)