Skip to content

Commit 519b905

Browse files
committed
Since Python 3.13, shutdown queues raise a QueueShutDown exception.
python/cpython#96471
1 parent 6a364f2 commit 519b905

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

tests/server/events/test_event_queue.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import asyncio
2+
import sys
23

34
from typing import Any
45
from unittest.mock import (
@@ -203,7 +204,11 @@ async def test_dequeue_event_closed_and_empty_no_wait(
203204
await event_queue.close()
204205
assert event_queue.is_closed()
205206
# Ensure queue is actually empty (e.g. by trying a non-blocking get on internal queue)
206-
with pytest.raises(asyncio.QueueEmpty):
207+
if sys.version_info < (3, 13):
208+
expected = asyncio.QueueEmpty
209+
else:
210+
expected = asyncio.QueueShutDown
211+
with pytest.raises(expected):
207212
event_queue.queue.get_nowait()
208213

209214
with pytest.raises(asyncio.QueueEmpty, match='Queue is closed.'):
@@ -217,9 +222,11 @@ async def test_dequeue_event_closed_and_empty_waits_then_raises(
217222
"""Test dequeue_event raises QueueEmpty eventually when closed, empty, and no_wait=False."""
218223
await event_queue.close()
219224
assert event_queue.is_closed()
220-
with pytest.raises(
221-
asyncio.QueueEmpty
222-
): # Should still raise QueueEmpty as per current implementation
225+
if sys.version_info < (3, 13):
226+
expected = asyncio.QueueEmpty
227+
else:
228+
expected = asyncio.QueueShutDown
229+
with pytest.raises(expected):
223230
event_queue.queue.get_nowait() # verify internal queue is empty
224231

225232
# This test is tricky because await event_queue.dequeue_event() would hang if not for the close check.

0 commit comments

Comments
 (0)