Skip to content

Commit 98fdaf4

Browse files
Change to 3.10 and provided detailed description about event queue usage
1 parent 8ec734c commit 98fdaf4

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description = "A2A Python SDK"
55
readme = "README.md"
66
license = { file = "LICENSE" }
77
authors = [{ name = "Google LLC", email = "[email protected]" }]
8-
requires-python = ">=3.12"
8+
requires-python = ">=3.10"
99
keywords = ["A2A", "A2A SDK", "A2A Protocol", "Agent2Agent"]
1010
dependencies = [
1111
"httpx>=0.28.1",
@@ -22,7 +22,7 @@ classifiers = [
2222
"Intended Audience :: Developers",
2323
"Programming Language :: Python",
2424
"Programming Language :: Python :: 3",
25-
"Programming Language :: Python :: 3.12",
25+
"Programming Language :: Python :: 3.10",
2626
"Operating System :: OS Independent",
2727
"Topic :: Software Development :: Libraries :: Python Modules",
2828
"License :: OSI Approved :: Apache Software License",

src/a2a/server/events/event_queue.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,20 @@ def enqueue_event(self, event: Event):
6161
async def dequeue_event(self, no_wait: bool = False) -> Event:
6262
"""Dequeues an event from the queue.
6363
64+
This implementation expects that dequeue to raise an exception when
65+
the queue has been closed. In python 3.13+ this is naturally provided
66+
by the QueueShutDown exception generated when the queue has closed and
67+
the user is awaiting the queue.get method. Python<=3.12 this needs to
68+
manage this lifecylce itself. The current implementation can lead to
69+
blocking if the dequeue_event is called before the EventQueue has been
70+
closed but when there are no events on the queue. Two ways to avoid this
71+
are to call this with no_wait = True which won't block, but is the
72+
callers responsibility to retry as appropriate. Alternatively, one can
73+
use a async Task management solution to cancel the get task if the queue
74+
has closed or some other condition is met. The implementation of the
75+
EventConsumer uses an async.wait with a timeout to abort the
76+
dequeue_event call and retry, when it will return with a closed error.
77+
6478
Args:
6579
no_wait: If True, retrieve an event immediately or raise `asyncio.QueueEmpty`.
6680
If False (default), wait until an event is available.

0 commit comments

Comments
 (0)