- Notifications
You must be signed in to change notification settings - Fork675
feat(client): automatically retry on HTTP 409 Resource lock#2326
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
lmilbaum commentedOct 18, 2022
Unit tests might increase the confidence that the code is working as expected. Would you mind adding unit tests? |
nejch left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
@pspacek thanks for the quick work here! Just a few nits.
Regarding unit tests and your question in#2325 (comment).
We have some vendored code from httmock for a similar reason (redirects). I think you might be able to reuse it here?
https://github.com/python-gitlab/python-gitlab/blob/main/tests/unit/helpers.py
See how it's used in the redirect tests:
https://github.com/python-gitlab/python-gitlab/blob/main/tests/unit/test_gitlab_http_methods.py#L310-L317
Let us know if you need help with that :) That's a shame about responses though.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
nejch commentedOct 20, 2022
And@pspacek we're also ok to go ahead without the unit tests if it's too complicated and we open a follow-up issue to resolve on our end :) |
nejch commentedDec 4, 2022
Hi@pspacek! Let us know if you'd like to finish this PR, or if we should push to your branch to get this merged (either way you'll be credited as the commit author). Thanks again for the contribution! |
pspacek commentedDec 5, 2022
@nejch I'm sorry, I have no time to work on this. Feel free to do whatever you like. |
| defresponse_callback( | ||
| response:requests.models.Response, | ||
| )->requests.models.Response: | ||
| """We need a callback that adds a resource lock reason only on first call""" | ||
| nonlocalretried | ||
| ifnotretried: | ||
| response.reason="Resource lock" | ||
| retried=True | ||
| returnresponse |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
We're mostly doing this becauseresponses doesn't support mockingResponse.reason as@pspacek already found out in#2325 (comment).
nejch left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
codecov-commenter commentedDec 5, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Codecov Report
@@ Coverage Diff @@## main #2326 +/- ##======================================= Coverage 96.13% 96.13% ======================================= Files 84 85 +1 Lines 5534 5569 +35 =======================================+ Hits 5320 5354 +34- Misses 214 215 +1
Flags with carried forward coverage won't be shown.Click here to find out more.
|
nejch commentedDec 19, 2022
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
lmilbaum left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
LGTM
Fixes:#2325