Fix LaunchService._is_idle() to consider active asyncio background tasks - #996
Open
wjwwood wants to merge 1 commit into
Open
Fix LaunchService._is_idle() to consider active asyncio background tasks#996wjwwood wants to merge 1 commit into
wjwwood wants to merge 1 commit into
Conversation
|
Tick the box to add this pull request to the merge queue (same as
|
Considers non-internal active asyncio tasks in `LaunchService._is_idle()` to ensure background tasks (such as asynchronous process execution) have a chance to complete and be managed during shutdown, rather than terminating prematurely and leaving orphaned child processes. Fixes #747 Reuses test case from #901 Co-authored-by: MegaIng <26136419+MegaIng@users.noreply.github.com> Signed-off-by: William Woodall <wjwwood@google.com>
wjwwood
force-pushed
the
wjwwood/fix_is_idle_background_tasks
branch
from
August 14, 2026 21:53
7cb2fe4 to
fd28024
Compare
Member
Author
|
Pulls: #996 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR updates
LaunchService._is_idle()to account for activeasyncio.Taskinstances running in the event loop that are not tracked as entity/completion futures.When an error occurs during launch description evaluation (e.g. invalid action/node argument or failure during
execute()), previously launched processes might still be in the middle of asynchronous setup. WhenLaunchService._is_idle()exited immediately, these subprocesses were orphaned because the main event loop exited before theirProcessStarted/OnShutdownhandlers could be processed.This addresses the deadlock issue found in #901 by excluding
LaunchService's internal event-processing task (__process_one_event_task) and main task (__this_task) when inspecting active tasks.Fixes #747
Supersedes #901
Is this user-facing behavior change?
No. Child processes started before an exception during launch are now reliably terminated during shutdown rather than orphaned.
Did you use Generative AI?
Yes, Gemini 3.7 Flash.