You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(ai): cancel DataConn._monitor_pipes task on disconnect (#2940) - #2991
No actionable comments were generated in the recent review.
Walkthrough
DataConn now stops its pipe monitor during disconnection. DataServer runs connection and EaaS cleanup after transport acceptance, including when acceptance raises an exception.
Changes: Data connection cleanup
Layer / File(s)
Summary
Stop the DataConn monitor packages/ai/src/ai/modules/data/data_conn.py
Disconnection invokes disconnect(). That method handles missing shutdown or pipe state, awaits the monitor task while suppressing cancellation, and returns when no pipes remain.
Run cleanup after transport acceptance packages/ai/src/ai/modules/data/data_server.py, packages/ai/tests/ai/modules/data/test_data_conn.py
The server awaits connection cleanup and runs cleanup in a finally block. Tests cover monitor shutdown and EaaS state reset when transport acceptance raises; the exception propagates.
Issue 2940 describes a pending DataConn._monitor_pipes task after the data connection closes. This change stops and awaits the monitor task during connection cleanup.
This change stops the data connection's pipe monitor on disconnect and runs cleanup even when accepting the transport fails, which addresses the pending-task warning at shutdown. No concrete merge-blocking risk remains after review.
Pre-merge checks: 4 · 1
Failed checks: 1 inconclusive
Check name
Status
Explanation
Resolution
Title check
The title names a cancellation of the DataConn._monitor_pipes task on disconnect, but the raw summary does not describe that change. The summary describes disconnect() tolerating missing state, awaiti…
Confirm that the diff cancels DataConn._monitor_pipes on disconnect. The summary and objectives use different names and calls (disconnect() versus close(), and _monitor_task). Align the title with the actual mechanism. Also confirm the issu…
Passed checks: 4 passed
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check
Issue #2940 requires the DataConn._monitor_pipes task to finish during task shutdown. DataConn.on_disconnected() now calls disconnect(). DataServer.listen() calls its disconnection handler in a finall…
Out of Scope Changes check
The changes stay within issue #2940. They add connection cleanup, ensure cleanup runs when transport acceptance raises, reset the EaaS connection state, and test these shutdown paths. These changes di…
Docstring Coverage
Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Full details: Linked Issues check
Explanation
Issue #2940 requires the DataConn._monitor_pipes task to finish during task shutdown. DataConn.on_disconnected() now calls disconnect(). DataServer.listen() calls its disconnection handler in a finally block, including transport-accept failures. disconnect() sets _shutdown_event and awaits _monitor_task. The added tests verify that the monitor task finishes on both shutdown paths.
Full details: Out of Scope Changes check
Explanation
The changes stay within issue #2940. They add connection cleanup, ensure cleanup runs when transport acceptance raises, reset the EaaS connection state, and test these shutdown paths. These changes directly support reliable monitor-task shutdown.
Full details: Docstring Coverage
Explanation
Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 4 functions across 3 files.
Full details: Title check
Explanation
The title names a cancellation of the DataConn._monitor_pipes task on disconnect, but the raw summary does not describe that change. The summary describes disconnect() tolerating missing state, awaiting the monitor task with cancellation suppressed, and try/finally handling in DataServer.listen. The objectives describe tracking the task in _monitor_task and canceling it in close(). The title's subject matches the objectives and linked issue #2940, but the code summary does not show the cancel-on-disconnect behavior being added. The title is also tied to a different issue number than the PR objectives, which reference #2991.
Resolution
Confirm that the diff cancels DataConn._monitor_pipes on disconnect. The summary and objectives use different names and calls (disconnect() versus close(), and _monitor_task). Align the title with the actual mechanism. Also confirm the issue number, because the title cites #2940 while the objectives cite PR #2991.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
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
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.
Summary
asyncio.create_task(self._monitor_pipes())handle onDataConn._monitor_taskand cancel/await it inDataConn.close().await conn.close()insideDataServer.on_disconnectso the monitor task is cleanly cancelled before loop teardown._monitor_taskis cancelled and awaited whenDataConn.close()is called.Fixes #2940
Summary by CodeRabbit