Skip to content

fix: release reference count on non-terminal exit to prevent stale registry entries#1079

Merged
ishymko merged 4 commits into
mainfrom
ishymko/active-task
May 26, 2026
Merged

fix: release reference count on non-terminal exit to prevent stale registry entries#1079
ishymko merged 4 commits into
mainfrom
ishymko/active-task

Conversation

@ishymko
Copy link
Copy Markdown
Member

@ishymko ishymko commented May 26, 2026

Handles cases when producer finishes without reaching terminal task state, it's symmetrical to ActiveTask.start where the counter is increased on producer and consumer creation.

… registry entries

Handles cases when producer finishes without reaching terminal task state.
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors task cleanup by moving the reference count decrement logic from _handle_terminal_state to the end of the _run_producer method's finally block in active_task.py. It also extracts the ResumingAgent test helper to the module level and adds a new integration test for resuming tasks across RPC event loops. A critical issue was identified in _run_producer where the reference count decrement and cleanup could be skipped if the preceding asynchronous queue closures are cancelled or raise an exception, potentially leading to resource leaks. It is recommended to wrap the queue closures in a nested try...finally block to guarantee cleanup.

Comment thread src/a2a/server/agent_execution/active_task.py Outdated
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 26, 2026

🧪 Code Coverage (vs main)

⬇️ Download Full Report

Base PR Delta
src/a2a/server/agent_execution/active_task.py 95.96% 95.92% 🔴 -0.03%
Total 93.07% 93.07% ⚪️ -0.00%

Generated by coverage-comment.yml

@ishymko ishymko marked this pull request as ready for review May 26, 2026 11:26
@ishymko ishymko requested a review from a team as a code owner May 26, 2026 11:26
@ishymko ishymko changed the title fix: release producer reference on non-terminal exit to prevent stale registry entries fix: release reference count on non-terminal exit to prevent stale registry entries May 26, 2026
@ishymko ishymko merged commit 501255c into main May 26, 2026
38 checks passed
@ishymko ishymko deleted the ishymko/active-task branch May 26, 2026 14:59
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.

2 participants