Skip to content

fix: aclose() blocks for close_timeout when child is externally killed#5930

Open
arpesenti wants to merge 7 commits into
livekit:mainfrom
arpesenti:fix-aclose-race-on-external-sigterm
Open

fix: aclose() blocks for close_timeout when child is externally killed#5930
arpesenti wants to merge 7 commits into
livekit:mainfrom
arpesenti:fix-aclose-race-on-external-sigterm

Conversation

@arpesenti
Copy link
Copy Markdown
Contributor

Fixes #5929

When the supervised process is killed by an external SIGTERM (e.g. process-group signal) before aclose() is called, the IPC channel is already closed. aclose() sends ShutdownRequest anyway (suppressed) then waits for ShutdownRequestAck via _shutdown_ack_fut. This future is resolved by _read_ipc_task when the channel closes, but that runs as a separate asyncio task — if the event loop hasn't processed it yet, aclose() blocks for the full close_timeout.

Fix: check is_alive() before sending ShutdownRequest. If the process is already dead, resolve both pending futures immediately.

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 3 additional findings.

Open in Devin Review

@arpesenti arpesenti force-pushed the fix-aclose-race-on-external-sigterm branch from 56954fc to bf1c5bd Compare June 2, 2026 09:36
devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SupervisedProc.aclose() blocks for full close_timeout when child is externally SIGTERM'd

1 participant