From 212e52743147c50092e70f37684357df776cf70a Mon Sep 17 00:00:00 2001 From: livepeer-tessa Date: Fri, 10 Apr 2026 06:24:36 +0000 Subject: [PATCH] fix: suppress ClientConnectionError in frames() generator teardown During session close, the async generator's finally block awaits the producer task which may raise aiohttp.ClientConnectionError when the connection was already dropped. This is expected during teardown but was not suppressed, causing asyncio to log 'Task exception was never retrieved' noise on every clean session close. Add aiohttp.ClientConnectionError to the suppress() context alongside the existing asyncio.CancelledError so teardown-time connection drops are silently discarded. Fixes daydreamlive/scope#897 Signed-off-by: livepeer-tessa --- src/livepeer_gateway/media_output.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/livepeer_gateway/media_output.py b/src/livepeer_gateway/media_output.py index f21d385..a5aa924 100644 --- a/src/livepeer_gateway/media_output.py +++ b/src/livepeer_gateway/media_output.py @@ -12,6 +12,8 @@ from contextlib import suppress from typing import AsyncIterator, Collection, Optional +import aiohttp + from .errors import LivepeerGatewayError from .media_decode import ( AudioDecodedMediaFrame, @@ -237,7 +239,7 @@ async def _feed() -> None: decoder.stop() if not producer_task.done(): producer_task.cancel() - with suppress(asyncio.CancelledError): + with suppress(asyncio.CancelledError, aiohttp.ClientConnectionError): await producer_task await asyncio.to_thread(decoder.join) self._last_decoder_stats = decoder.get_stats()