[Bugfix] Catch asyncio.TimeoutError so duplex serving starts on Python 3.10 (#7412)

Signed-off-by: Tianyao Wu <rayroy31@gmail.com>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Alicia <115451386+congw729@users.noreply.github.com>
This commit is contained in:
authored and GitHub committed 2026-09-21 18:34:58 -07:00
1 parent 1d3dc8bf83
commit 085cf0ff34
6 files changed
+76 -4

No files matched your search

+2 -1
View File
@@ -141,7 +141,8 @@ class DuplexSessionTasks:
task.cancel()
try:
await asyncio.wait_for(asyncio.gather(*tasks, return_exceptions=True), timeout=timeout_s)
except TimeoutError:
# asyncio.TimeoutError is not the builtin TimeoutError before Python 3.11.
except (TimeoutError, asyncio.TimeoutError):
pass
if cancelled_tail is not None and self.append_tail is cancelled_tail:
self.append_tail = None
+3 -1
View File
@@ -699,7 +699,9 @@ class DuplexSessionManager:
while not shutdown_event.is_set():
try:
await asyncio.wait_for(shutdown_event.wait(), timeout=interval)
except TimeoutError:
# The timeout is this loop's tick. asyncio.TimeoutError is not the builtin
# TimeoutError before Python 3.11, so catch both or the tick escapes the loop.
except (TimeoutError, asyncio.TimeoutError):
try:
await self.reap_expired()
except Exception:
+2 -1
View File
@@ -1486,7 +1486,8 @@ class DuplexSessionRunner:
active_task.cancel()
try:
await asyncio.wait_for(asyncio.gather(active_task, return_exceptions=True), timeout=0.25)
except TimeoutError:
# asyncio.TimeoutError is not the builtin TimeoutError before Python 3.11.
except (TimeoutError, asyncio.TimeoutError):
pass
if notify:
self.emit(