From a44de6ba9b6799008584c17bbf1044c3582f2fe2 Mon Sep 17 00:00:00 2001 From: yryzhan Date: Wed, 20 May 2026 17:17:03 +0200 Subject: [PATCH] fix(streaming): cancel timed-out future before retrying in _put Prevents accumulation of pending Queue.put coroutines in the event loop when the producer retries after a timeout. Each timed-out future is now cancelled before the next attempt. --- litellm/litellm_core_utils/streaming_handler.py | 1 + 1 file changed, 1 insertion(+) diff --git a/litellm/litellm_core_utils/streaming_handler.py b/litellm/litellm_core_utils/streaming_handler.py index d2ab43fdfaf..fcfecf7c438 100644 --- a/litellm/litellm_core_utils/streaming_handler.py +++ b/litellm/litellm_core_utils/streaming_handler.py @@ -109,6 +109,7 @@ class _SyncIteratorToQueue: fut.result(timeout=0.5) return except TimeoutError: + fut.cancel() continue except Exception: return