Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle #925 rate limit error #1364

Merged

Conversation

stefanoboriero
Copy link
Contributor

@stefanoboriero stefanoboriero commented Apr 19, 2022

  • add status code 429 to the list of retriable errors

FIXES #925

@stefanoboriero stefanoboriero force-pushed the ISSUE-925-handle-rate-limiting branch from dada6ea to 353d4fe Compare April 19, 2022 21:59
@adehad adehad added the feature label Apr 23, 2022
Copy link
Contributor

@adehad adehad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really appreciate you making this, I've added a few comments

(also the GitHub way of referencing an issue would be to use the # symbol and then the number, i.e. #925)

tests/test_resilientsession.py Outdated Show resolved Hide resolved
jira/resilientsession.py Outdated Show resolved Hide resolved
@stefanoboriero stefanoboriero force-pushed the ISSUE-925-handle-rate-limiting branch 2 times, most recently from 7519d61 to 2112630 Compare April 24, 2022 11:10
jira/resilientsession.py Outdated Show resolved Hide resolved
jira/resilientsession.py Outdated Show resolved Hide resolved
@stefanoboriero stefanoboriero force-pushed the ISSUE-925-handle-rate-limiting branch 2 times, most recently from 8b473fb to d9aaa1e Compare April 26, 2022 21:01
Copy link
Contributor

@adehad adehad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome stuff, just a minor change and otherwise looks good.


Regarding:

#1364 (comment)

Same is true for the header "X-RateLimit-Remaining" which is logged with the rest of the headers on line 141, but with the difference that is logged at debug level. If you think that's enough, I'd remove the log of this specific header in the handling of the 429 response code in favour of the more generic header dump

I prefer the current implementation with the specific error message at the warning level. My reasoning would be:

  1. It is more like for the log level to be set to info or warning levels than to debug levels.
  2. It is a way for the code to document itself, and additionally be more meaningful for the end user than just a dump of headers they need to know the implementation details to understand

But happy to hear your thoughts

jira/resilientsession.py Outdated Show resolved Hide resolved
@adehad adehad changed the title ISSUE-925: Handle rate limit error Handle #925 rate limit error Apr 27, 2022
jira/resilientsession.py Outdated Show resolved Hide resolved
* add status code 429 to the list of retriable errors

FIXES pycontribs#925
@stefanoboriero stefanoboriero force-pushed the ISSUE-925-handle-rate-limiting branch from d9aaa1e to 0a51c50 Compare April 27, 2022 22:03
@stefanoboriero
Copy link
Contributor Author

stefanoboriero commented Apr 27, 2022

About this comment

I prefer the current implementation with the specific error message at the warning level. My reasoning would be:

It is more like for the log level to be set to info or warning levels than to debug levels.
It is a way for the code to document itself, and additionally be more meaningful for the end user than just a dump of headers they need to know the implementation details to understand

But happy to hear your thoughts

I agree with you, let's keep the more detailed log message at warning level in the status_code handling bit, since as you said it's unlikely users have debug log level enabled when runtime issues like this happen, and we add specific context about retries in the log message.

Copy link
Contributor

@adehad adehad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks for pushing through this.

@adehad adehad merged commit e2dd9b4 into pycontribs:main Apr 29, 2022
@adhamselman
Copy link

Hello,
https://github.com/pycontribs/jira/pull/1364/files#diff-0605333df4b31ca7f97b2591e3bcba9c71ea201f4a88e383316e7f6c1c478e06R127
Just wondering, what is the point of only logging the value of 'retry-after' instead of taking it into consideration when implementing the backoff?

@adehad
Copy link
Contributor

adehad commented Aug 16, 2022

@adhamselman
Completely understand where you are coming from, and perhaps there is a further improvement by not bothering to retry if this duration is already greater than the max_retry_delay

@adhamselman
Copy link

Not just that. The backoff delay may be calculated to (for example) 20 seconds but the 'retry-after' value may be 30.
I'm not entirely sure but if the retry value is 30 and we retry after 20 seconds, i think the server may penalize you for being too aggressive and increase the wait time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Handle 429 rate limiting messages from Jira
3 participants