We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 49c7979 commit 99b2325Copy full SHA for 99b2325
src/huggingface_hub/inference/_common.py
@@ -374,9 +374,12 @@ def _format_chat_completion_stream_output(
374
375
376
async def _async_yield_from(client: "ClientSession", response: "ClientResponse") -> AsyncIterable[bytes]:
377
- async for byte_payload in response.content:
378
- yield byte_payload.strip()
379
- await client.close()
+ try:
+ async for byte_payload in response.content:
+ yield byte_payload.strip()
380
+ finally:
381
+ # Always close the underlying HTTP session to avoid resource leaks
382
+ await client.close()
383
384
385
# "TGI servers" are servers running with the `text-generation-inference` backend.
0 commit comments