fix(streaming): avoid duplicate chunk on cancel race in _put

When fut.cancel() returns False the coroutine already completed and
the item is in the queue. Previously the loop would continue and
enqueue the same item again. Now we return immediately when cancel
fails, preventing duplicate chunks under tight timing.
This commit is contained in:
yryzhan 2026-05-20 18:47:33 +02:00
parent a44de6ba9b
commit 4b980d9d9c

View file

@ -109,7 +109,8 @@ class _SyncIteratorToQueue:
fut.result(timeout=0.5)
return
except TimeoutError:
fut.cancel()
if not fut.cancel():
return
continue
except Exception:
return