Skip to content

Commit 7f0c3d3

Browse files
committed
Add comment for queue read timeout
1 parent 072ca6e commit 7f0c3d3

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/a2a/server/events/event_consumer.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ async def consume_all(self) -> AsyncGenerator[Event]:
5050
if self._exception:
5151
raise self._exception
5252
try:
53+
# We use a timeout when waiting for an event from the queue.
54+
# This is required because it allows the loop to check if
55+
# `self._exception` has been set by the `agent_task_callback`.
56+
# Without the timeout, loop might hang indefinitely if no events are
57+
# enqueued by the agent and the agent simply threw an exception
5358
event = await asyncio.wait_for(self.queue.dequeue_event(), timeout=self._timeout)
5459
logger.debug(
5560
f'Dequeued event of type: {type(event)} in consume_all.'

0 commit comments

Comments
 (0)