fix(gateway): track background watcher tasks in _background_tasks - #14748
Closed
sprmn24 wants to merge 1 commit into
Closed
fix(gateway): track background watcher tasks in _background_tasks#14748sprmn24 wants to merge 1 commit into
sprmn24 wants to merge 1 commit into
Conversation
Recovered process watchers, session expiry watcher, and platform reconnect watcher were launched with asyncio.create_task() but never registered in _background_tasks. This meant shutdown could not cancel or join them, leading to orphaned tasks and silent exception drops. Also guard the signal-handler runner.stop() task with a done callback that logs any exception instead of silently discarding it. Fixes: - _run_process_watcher (recovered watchers loop) — register each task - _session_expiry_watcher — store handle and register - _platform_reconnect_watcher — store handle and register - signal handler runner.stop() — add exception-logging done callback
Collaborator
|
Likely duplicate of #6790 — same fix: register fire-and-forget watcher tasks in _background_tasks set in GatewayRunner. |
1 similar comment
Collaborator
|
Likely duplicate of #6790 — same fix: register fire-and-forget watcher tasks in _background_tasks set in GatewayRunner. |
Contributor
Author
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.
What does this PR do?
Four
asyncio.create_task()calls ingateway/run.pywere launched fire-and-forget — the task handles were discarded immediately, so_background_tasksnever tracked them. On shutdown, these tasks could not be cancelled or joined, causing orphaned tasks and silently dropped exceptions.Type of Change
Root Cause
The existing pattern used throughout the file is:
Three watcher tasks and the signal handler's
runner.stop()call skipped this registration entirely.Changes Made
_run_process_watcher(recovered watchers loop) — each task now stored and registered with discard callback_session_expiry_watcher— task handle stored and registered in_background_tasks_platform_reconnect_watcher— task handle stored and registered in_background_tasksrunner.stop()— stored in_stop_taskwith exception-logging done callback (_background_tasksnot accessible in signal handler scope)How to Test
Task was destroyed but it is pendingwarnings in logsChecklist
_background_taskspattern used throughout the file