Skip to content

gh-157259: Record awaited-by edge for asyncio subprocess pipe-connect task - #159556

Open
JohnnyWilson16 wants to merge 1 commit into
python:mainfrom
JohnnyWilson16:fix-gh-157259-subprocess-awaited-by
Open

JohnnyWilson16 wants to merge 1 commit into
python:mainfrom
JohnnyWilson16:fix-gh-157259-subprocess-awaited-by

Conversation

@JohnnyWilson16

Copy link
Copy Markdown

Fixes gh-157259.

When BaseSubprocessTransport spawns an internal task for self._connect_pipes(waiter), the caller awaits the waiter Future directly, leaving the internal pipe-connect task disconnected in asyncio.print_call_graph() and asyncio.capture_call_graph().

This change registers the awaited-by relationship via futures.future_add_to_awaited_by(task, waiter) during transport startup and discards the edge in a done callback once _connect_pipes finishes or is cancelled, ensuring clean disposal with no references leaked.

Adds regression test test_stack_subprocess_connect_pipes to test_asyncio.test_graph under CallStackTestBase (covering both C and Python call-graph backends).

…onnect task

When BaseSubprocessTransport creates a task for _connect_pipes(waiter),
register the awaited-by relationship between task and waiter so that
asyncio.print_call_graph() and asyncio.capture_call_graph() connect
the background pipe-connect task to the awaiting parent task. Discard the
edge in a done callback once _connect_pipes completes or is cancelled.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

asyncio subprocess spawn does not record the awaiting task

1 participant