Update client.py: raise error on 429 get_config (#9754)

* Update client.py: raise error on 429 get_config

best not request to again

* add changeset

* lint

* fix error

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
This commit is contained in:
Yanis Lukes 2024-10-18 20:23:21 +03:00 committed by GitHub
parent 88c8793276
commit 36a5076909
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 1 deletions

View File

@ -0,0 +1,6 @@
---
"gradio": patch
"gradio_client": patch
---
fix:Update client.py: raise error on 429 get_config

View File

@ -869,9 +869,13 @@ class Client:
raise AuthenticationError(
f"Could not load {self.src} as credentials were not provided. Please login."
)
elif r.status_code == 429:
raise utils.TooManyRequestsError(
"Too many requests to the API, please try again later."
) from None
else: # to support older versions of Gradio
r = httpx.get(
self.src_prefixed,
self.src,
headers=self.headers,
cookies=self.cookies,
verify=self.ssl_verify,