Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged
nejch merged 2 commits intopython-gitlab:mainfrompspacek:http-409-lock-retry
Dec 19, 2022

Conversation

@pspacek
Copy link
Contributor

Fixes:#2325

nejch reacted with thumbs up emoji
@lmilbaum
Copy link

Unit tests might increase the confidence that the code is working as expected. Would you mind adding unit tests?

nejch reacted with thumbs up emoji

Copy link
Member

@nejchnejch left a 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.

@nejch
Copy link
Member

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
Copy link
Member

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
Copy link
ContributorAuthor

@nejch I'm sorry, I have no time to work on this. Feel free to do whatever you like.

nejch reacted with thumbs up emoji

Comment on lines +379 to +389
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
Copy link
Member

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).

@nejchnejch changed the titleDraft: feat(client): automatically retry on HTTP 409 Resource lockfeat(client): automatically retry on HTTP 409 Resource lockDec 5, 2022
Copy link
Member

@nejchnejch left a comment

Choose a reason for hiding this comment

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

This LGTM but I added a commit in25446cf to finish the PR so will need someone else to do the merge.

Thanks again@pspacek!

@codecov-commenter
Copy link

codecov-commenter commentedDec 5, 2022
edited
Loading

Codecov Report

Merging#2326 (1a37bab) intomain (c7cf0d1) willincrease coverage by0.00%.
The diff coverage is90.90%.

@@           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
FlagCoverage Δ
api_func_v482.58% <54.54%> (+<0.01%)⬆️
cli_func_v482.83% <45.45%> (-0.06%)⬇️
unit87.48% <81.81%> (+0.04%)⬆️

Flags with carried forward coverage won't be shown.Click here to find out more.

Impacted FilesCoverage Δ
gitlab/client.py98.38% <90.90%> (-0.18%)⬇️
gitlab/v4/objects/__init__.py100.00% <0.00%> (ø)
gitlab/v4/objects/resource_groups.py100.00% <0.00%> (ø)
gitlab/v4/objects/projects.py98.86% <0.00%> (+<0.01%)⬆️

@nejch
Copy link
Member

Unit tests might increase the confidence that the code is working as expected. Would you mind adding unit tests?

@lmilbaum I've added a commit on top of the author's to rework and add tests (1a37bab). Maybe you can take a look and we can merge before the next release.

@lmilbaumlmilbaum self-requested a reviewDecember 19, 2022 20:02
Copy link

@lmilbaumlmilbaum left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nejchnejchnejch approved these changes

+1 more reviewer

@lmilbaumlmilbaumlmilbaum approved these changes

Reviewers whose approvals may not affect merge requirements

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

[feature request] auto-retry when HTTP 409 Conflict: Resource lock is received

6 participants

@pspacek@lmilbaum@nejch@codecov-commenter@JohnVillalovos@max-wittig

[8]ページ先頭

©2009-2025 Movatter.jp