Skip to content

Commit 0e70bda

Browse files
committed
fix(clear_events): handle Python 3.13 QueueShutDown exception for mypy compatibility
- Replace getattr-based exception handling with explicit version check - Use type(e).__name__ comparison to identify QueueShutDown in Python 3.13+ - Re-raise unexpected exceptions to maintain proper error propagation - Fixes mypy error: Exception type must be derived from BaseException
1 parent e5d41c2 commit 0e70bda

File tree

4 files changed

+2035
-6
lines changed

4 files changed

+2035
-6
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ __pycache__
55
.mypy_cache
66
.pytest_cache
77
.ruff_cache
8-
.venv
8+
.venv-3.11
99
coverage.xml
1010
.nox
1111
spec.json

.python-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.10
1+
3.13

src/a2a/server/events/event_queue.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,11 +192,17 @@ async def clear_events(self, clear_child_queues: bool = True) -> None:
192192
)
193193
self.queue.task_done()
194194
cleared_count += 1
195-
except (
196-
asyncio.QueueEmpty,
197-
getattr(asyncio, 'QueueShutDown', asyncio.QueueEmpty),
198-
):
195+
except asyncio.QueueEmpty:
199196
pass
197+
except Exception as e:
198+
# Handle Python 3.13+ QueueShutDown
199+
if (
200+
sys.version_info >= (3, 13)
201+
and type(e).__name__ == 'QueueShutDown'
202+
):
203+
pass
204+
else:
205+
raise
200206

201207
if cleared_count > 0:
202208
logger.debug(

0 commit comments

Comments
 (0)