Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 23 additions & 6 deletions Lib/test/test_external_inspection.py
Original file line number Diff line number Diff line change
Expand Up @@ -2033,14 +2033,31 @@ def leaf(depth):
leaf(300)
"""
with _managed_subprocess([sys.executable, "-c", script]) as process:
for _ in busy_retry(SHORT_TIMEOUT):
# RemoteUnwinder can attach during interpreter startup. Wait
# until leaf() is on the stack so the sample window observes it.
unwinder = None
for _ in busy_retry(
SHORT_TIMEOUT,
"child did not reach leaf() before sampling",
):
if unwinder is None:
try:
unwinder = RemoteUnwinder(
process.pid,
native=True,
gc=False,
cache_frames=False,
)
except RuntimeError:
continue
try:
unwinder = RemoteUnwinder(
process.pid, native=True, gc=False, cache_frames=False,
)
except RuntimeError:
threads = unwinder.get_stack_trace()[0].threads
except TRANSIENT_ERRORS:
continue
break
if threads and any(
frame.funcname == "leaf" for frame in threads[0].frame_info
):
break
samples = 0
for _ in range(10_000):
try:
Expand Down
Loading