File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1717from __future__ import annotations
1818
1919import asyncio
20+ import logging
2021import sys
2122from typing import AsyncGenerator
2223from typing import ClassVar
3233from .invocation_context import InvocationContext
3334from .parallel_agent_config import ParallelAgentConfig
3435
36+ logger = logging .getLogger ('google_adk.' + __name__ )
37+
3538
3639def _create_branch_ctx_for_sub_agent (
3740 agent : BaseAgent ,
@@ -65,9 +68,15 @@ async def process_an_agent(events_for_one_agent):
6568 await queue .put ((event , resume_signal ))
6669 # Wait for upstream to consume event before generating new events.
6770 await resume_signal .wait ()
71+ except asyncio .CancelledError :
72+ logger .info ('Agent run cancelled.' )
73+ raise
6874 finally :
6975 # Mark agent as finished.
70- await queue .put ((sentinel , None ))
76+ try :
77+ await queue .put ((sentinel , None ))
78+ except Exception as e :
79+ logger .warning ('Failed to put sentinel on queue: %s' , e )
7180
7281 async with asyncio .TaskGroup () as tg :
7382 for events_for_one_agent in agent_runs :
You can’t perform that action at this time.
0 commit comments