mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-06-06 13:09:39 +02:00
Improve Confluence rate limit handling
This commit is contained in:
parent
f45e2476d0
commit
8e89d00e32
@ -10,6 +10,9 @@ from retry import retry
|
|||||||
F = TypeVar("F", bound=Callable[..., Any])
|
F = TypeVar("F", bound=Callable[..., Any])
|
||||||
|
|
||||||
|
|
||||||
|
RATE_LIMIT_MESSAGE_LOWERCASE = "Rate limit exceeded".lower()
|
||||||
|
|
||||||
|
|
||||||
class ConfluenceRateLimitError(Exception):
|
class ConfluenceRateLimitError(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -27,7 +30,10 @@ def make_confluence_call_handle_rate_limit(confluence_call: F) -> F:
|
|||||||
try:
|
try:
|
||||||
return confluence_call(*args, **kwargs)
|
return confluence_call(*args, **kwargs)
|
||||||
except HTTPError as e:
|
except HTTPError as e:
|
||||||
if e.response.status_code == 429:
|
if (
|
||||||
|
e.response.status_code == 429
|
||||||
|
or RATE_LIMIT_MESSAGE_LOWERCASE in e.response.text.lower()
|
||||||
|
):
|
||||||
raise ConfluenceRateLimitError()
|
raise ConfluenceRateLimitError()
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user