huggingface / huggingface_hub

The official Python client for the Huggingface Hub.
https://huggingface.co/docs/huggingface_hub
Apache License 2.0
1.83k stars 471 forks source link

Close aiohttp client on error #2294

Closed Wauplin closed 1 month ago

Wauplin commented 1 month ago

Should fix warnings in optimum CI cc @dacorvo

At the moment if an error occurs while sending a POST with AsyncInferenceClient, we don't catch all errors. This PR makes sure that we close the connection "no matter what" and before raising the exception. Also added a test to ensure that.

HuggingFaceDocBuilderDev commented 1 month ago

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Wauplin commented 1 month ago

Thanks for the quick review @dacorvo :) Failing tests are unrelated so merging it now.