Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
516e4d2
FIX [Bug]#367: Client hangs when implementing AgentExecutor and awai…
meoow113 Aug 4, 2025
66526b9
Merge branch 'main' into fix-bug#367-client_hangs
holtskinner Aug 4, 2025
a5446e1
fix: #367 add immediate parameter to EventQueue.close() for forced qu…
Aug 6, 2025
42e83cb
The main updates in this pull request are as follows:
Aug 6, 2025
fbdc76f
update format
Aug 6, 2025
fbe67be
reduce lock contention in EventQueue.clear_events
meoow113 Aug 7, 2025
2af22c3
linter code
meoow113 Aug 7, 2025
8c85025
Merge branch 'main' into fix-bug#367-client_hangs
holtskinner Aug 7, 2025
c7516df
Merge branch 'main' into fix-bug#367-client_hangs
meoow113 Aug 8, 2025
94888c5
Merge branch 'main' into fix-bug#367-client_hangs
holtskinner Aug 8, 2025
dc217a1
Merge branch 'main' into fix-bug#367-client_hangs
holtskinner Aug 11, 2025
833c1b1
Merge branch 'main' into fix-bug#367-client_hangs
holtskinner Aug 12, 2025
811ebc7
Merge branch 'main' into fix-bug#367-client_hangs
holtskinner Aug 12, 2025
f5c751c
Merge branch 'main' into fix-bug#367-client_hangs
holtskinner Aug 12, 2025
e7e558f
Merge branch 'main' into fix-bug#367-client_hangs
holtskinner Aug 13, 2025
7119604
test: add comprehensive tests for EventQueue.close immediate paramete…
meoow113 Aug 14, 2025
e13b5d8
Merge branch 'a2aproject:main' into fix-bug#367-client_hangs
meoow113 Aug 14, 2025
a5234fc
Merge branch 'fix-bug#367-client_hangs' of https://github.com/meoow11…
meoow113 Aug 14, 2025
98cf92b
perf(clear_events): fix Ruff PERF203 by moving try/except outside the…
meoow113 Aug 14, 2025
671b881
perf(clear_events): fix Ruff PERF203 and add Py3.13 shutdown compatib…
meoow113 Aug 14, 2025
db58ecf
delete unrelevant files
meoow113 Aug 14, 2025
e5d41c2
lint code
meoow113 Aug 14, 2025
0e70bda
fix(clear_events): handle Python 3.13 QueueShutDown exception for myp…
meoow113 Aug 15, 2025
affc4ad
delete unrelevent file
meoow113 Aug 15, 2025
d3e95f2
Merge branch 'main' into fix-bug#367-client_hangs
meoow113 Aug 18, 2025
ee9e8e6
Merge branch 'main' into fix-bug#367-client_hangs
holtskinner Aug 20, 2025
40e1d88
Merge branch 'main' into fix-bug#367-client_hangs
holtskinner Aug 20, 2025
057da04
Regenerate uv.lock and remove pre-commit from main dependencies
holtskinner Aug 20, 2025
4f5013a
Revert changes to uv.lock
holtskinner Aug 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/a2a/server/events/event_consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ async def consume_all(self) -> AsyncGenerator[Event]:
# other part is waiting for an event or a closed queue.
if is_final_event:
logger.debug('Stopping event consumption in consume_all.')
await self.queue.clear_events()
Comment thread
meoow113 marked this conversation as resolved.
Outdated
await self.queue.close()
yield event
break
Expand Down
36 changes: 36 additions & 0 deletions src/a2a/server/events/event_queue.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import asyncio
import logging
import sys
Expand Down Expand Up @@ -154,3 +154,39 @@
def is_closed(self) -> bool:
"""Checks if the queue is closed."""
return self._is_closed

async def clear_events(self, clear_child_queues: bool = True) -> None:
"""Clears all events from the current queue and optionally all child queues.

This method removes all pending events from the queue without processing them.
Child queues can be optionally cleared based on the clear_child_queues parameter.

Args:
clear_child_queues: If True (default), clear all child queues as well.
If False, only clear the current queue, leaving child queues untouched.
"""
logger.debug('Clearing all events from EventQueue and child queues.')
async with self._lock:
# Clear all events from the queue, even if closed
cleared_count = 0
while not self.queue.empty():
try:
event = self.queue.get_nowait()
logger.debug(f'Discarding unprocessed event of type: {type(event)}, content: {event}')
self.queue.task_done()
cleared_count += 1
except asyncio.QueueEmpty:
break

if cleared_count > 0:
logger.debug(f'Cleared {cleared_count} unprocessed events from EventQueue.')

# Clear all child queues
if clear_child_queues:
child_tasks = []
for child in self._children:
child_tasks.append(asyncio.create_task(child.clear_events()))

if child_tasks:
await asyncio.wait(child_tasks, return_when=asyncio.ALL_COMPLETED)
Comment thread
meoow113 marked this conversation as resolved.
Outdated

Loading