Skip to content

Create GithubRetry.DEFAULT_* constants#3006

Open
jodelasur wants to merge 5 commits intoPyGithub:mainfrom
jodelasur:create-github-retry-default-constants
Open

Create GithubRetry.DEFAULT_* constants#3006
jodelasur wants to merge 5 commits intoPyGithub:mainfrom
jodelasur:create-github-retry-default-constants

Conversation

@jodelasur
Copy link
Copy Markdown
Contributor

Resolves #2970.

@jodelasur jodelasur requested a review from EnricoMi August 27, 2024 10:13
Copy link
Copy Markdown
Collaborator

@EnricoMi EnricoMi left a comment

Choose a reason for hiding this comment

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

almost there

from github.Requester import Requester

DEFAULT_SECONDARY_RATE_WAIT: int = 60
DEFAULT_STATUS_FORCELIST = list(range(500, 600))
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think we should also add 403 to the default.

Suggested change
DEFAULT_STATUS_FORCELIST = list(range(500, 600))
DEFAULT_STATUS_FORCELIST = list(range(500, 600)) + [403]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@jodelasur Any objections? Otherwise I would apply these changes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I guess this is OK. See my comment below though. May we could apply this and not the other one?

# to determine if we really retry that 403
kwargs["status_forcelist"] = kwargs.get("status_forcelist", list(range(500, 600))) + [403]
kwargs["allowed_methods"] = kwargs.get("allowed_methods", Retry.DEFAULT_ALLOWED_METHODS.union({"GET", "POST"}))
kwargs["status_forcelist"] = kwargs.get("status_forcelist", DEFAULT_STATUS_FORCELIST) + [403]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
kwargs["status_forcelist"] = kwargs.get("status_forcelist", DEFAULT_STATUS_FORCELIST) + [403]
kwargs["status_forcelist"] = kwargs.get("status_forcelist", DEFAULT_STATUS_FORCELIST)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Given a user provides a custom status_forcelist value without 403, the current logic will still add 403 on init. If we apply this change, this won't happen anymore and 403 won't be in the list. This could affect the custom 403 logic applied for GithubRetry. What do you think?

If you feel this is a non-issue, please go ahead and apply. I'll be offline for a week or so, and won't be able to check on this.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement GithubRetry DEFAULT_ALLOWED_METHODS and DEFAULT_STATUS_FORCELIST

2 participants