Skip to content

Commit dc9aad3

Browse files
committed
Handle the process runs shorter than expected
In this case the subprocess will go into zombie state until we can poll it. We can simply assume this is the case if it's still detected as running when we get a ValueError.
1 parent 3e325e8 commit dc9aad3

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Lib/profile/sample.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@ def sample(self, collector, duration_sec=10):
5757
break
5858
except (RuntimeError, UnicodeDecodeError, MemoryError, OSError):
5959
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
6068
except Exception as e:
6169
if not self._is_process_running():
6270
break
@@ -784,6 +792,8 @@ def main():
784792

785793
process = subprocess.Popen(cmd)
786794

795+
# If we are the ones starting the process, we need to wait until the
796+
# runtime state is initialized
787797
try:
788798
wait_for_process_and_sample(process.pid, sort_value, args)
789799
finally:

0 commit comments

Comments
 (0)