From 1c10aaa7facacf08f64406e835a426eaac92b7e9 Mon Sep 17 00:00:00 2001 From: Lucain Date: Fri, 22 Nov 2024 19:04:07 +0100 Subject: [PATCH] Use asyncio.sleep in AsyncInferenceClient (not time.sleep) (#2674) --- src/huggingface_hub/inference/_generated/_async_client.py | 2 +- utils/generate_async_inference_client.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/huggingface_hub/inference/_generated/_async_client.py b/src/huggingface_hub/inference/_generated/_async_client.py index 9206316473..57ff5a1d49 100644 --- a/src/huggingface_hub/inference/_generated/_async_client.py +++ b/src/huggingface_hub/inference/_generated/_async_client.py @@ -324,7 +324,7 @@ async def post( logger.info(f"Waiting for model to be loaded on the server: {error}") if "X-wait-for-model" not in headers and url.startswith(INFERENCE_ENDPOINT): headers["X-wait-for-model"] = "1" - time.sleep(1) + await asyncio.sleep(1) if timeout is not None: timeout = max(self.timeout - (time.time() - t0), 1) # type: ignore continue diff --git a/utils/generate_async_inference_client.py b/utils/generate_async_inference_client.py index a4b92f1d64..1738937df6 100644 --- a/utils/generate_async_inference_client.py +++ b/utils/generate_async_inference_client.py @@ -226,7 +226,7 @@ def _rename_to_AsyncInferenceClient(code: str) -> str: logger.info(f"Waiting for model to be loaded on the server: {error}") if "X-wait-for-model" not in headers and url.startswith(INFERENCE_ENDPOINT): headers["X-wait-for-model"] = "1" - time.sleep(1) + await asyncio.sleep(1) if timeout is not None: timeout = max(self.timeout - (time.time() - t0), 1) # type: ignore continue