Repository navigation
fix(server): close the event queues when ActiveTask.start() fails - #1422
Open
cchinchilla-dev wants to merge 1 commit into
Open
cchinchilla-dev wants to merge 1 commit into
cchinchilla-dev wants to merge 1 commit into
Conversation
🧪 Code Coverage (vs
|
| Base | PR | Delta | |
|---|---|---|---|
| src/a2a/server/agent_execution/active_task.py | 96.10% | 96.67% | 🟢 +0.57% |
| Total | 93.42% | 93.45% | 🟢 +0.03% |
Generated by coverage-comment.yml
This branch has not been deployed
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
Thank you for opening a Pull Request!
Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
CONTRIBUTINGGuide.fix:which represents bug fixes, and correlates to a SemVer patch.feat:represents a new feature, and correlates to a SemVer minor.feat!:, orfix!:,refactor!:, etc., which represent a breaking change (indicated by the!) and will result in a SemVer major.bash scripts/format.shfrom the repository root to format)Fixes #1421 🦕
Problem
Each
EventQueueSourcestarts its dispatcher task when it is created, andActiveTaskcreates two of them in__init__. When the setup instart()fails, because the stored task is in a terminal state or is missing, theexceptblock re-raises without closing them:A
SendMessageto a completed task goes through this path, so every rejected request leaves two_dispatch_looptasks pending until they are garbage collected and logged asTask was destroyed but it is pending!.Fix
The
exceptblock instart()(src/a2a/server/agent_execution/active_task.py) now closes_event_queue_agentand_event_queue_subscriberswithclose(immediate=True)before calling_on_cleanup, the same wayaclose()closes them.aclose()itself can't be used here because it takes_lock, whichstart()already holds.The change only touches the failure path, so a successful
start()is not affected.Test
A test was added to the existing suite at
tests/server/agent_execution/test_active_task.py:test_active_task_start_setup_failure_closes_event_queues: afterstart()fails on a completed task (UnsupportedOperationError) or a missing one (TaskNotFoundError), both dispatcher tasks are done.Both cases fail on
mainwith the dispatcher tasks still pending and pass with the fix. No existing test was modified or removed. Happy to adapt the test approach based on maintainer feedback.