python-zulip-api
python-zulip-api copied to clipboard
zulip.Client.call_endpoint: Add retry_on_rate_limit_error.
Hi :)
I'd like to suggest a new option for the call_endpoint
method of zulip.Client
. It's something I added to my bot. @timabbott suggested to also consider this for the API, see https://chat.zulip.org/#narrow/stream/378-api-design/topic/Rate.20limits/near/1217048 for the discussion.
Short description of the patch:
If the call_endpoint
method is called with the retry_on_rate_limit_error
parameter set to true, wait and retry automatically on rate limit errors.
@timabbott Thanks for the feedback! :+1:
I updated the code (the layout of the if-statement with the closing bracket on its own line has been done by ./tools/lint
btw. ;) ).
And you would also think that retry-after
has always been a float, not a string? I'm not sure how that has been handled by older Zulip versions. And I'm not sure what happened to the capitalized Retry-After
I found here...