Skip to content

Commit

Permalink
Use asyncio.sleep in AsyncInferenceClient (not time.sleep) (#2674)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wauplin authored Nov 22, 2024
1 parent fcecbb8 commit 1c10aaa
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/huggingface_hub/inference/_generated/_async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion utils/generate_async_inference_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1c10aaa

Please sign in to comment.