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

Improvements to HTTP requests#1392

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
max-wittig merged 2 commits intopython-gitlab:masterfrombbatliner:patch-1
Apr 23, 2021
Merged
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 18 additions & 10 deletionsgitlab/client.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -451,6 +451,10 @@ def http_request(
post_data: Optional[Dict[str, Any]] = None,
streamed: bool = False,
files: Optional[Dict[str, Any]] = None,
timeout: Optional[float] = None,
obey_rate_limit: bool = True,
retry_transient_errors: bool = False,
max_retries: int = 10,
**kwargs: Any,
) -> requests.Response:
"""Make an HTTP request to the Gitlab server.
Expand All@@ -465,6 +469,14 @@ def http_request(
json)
streamed (bool): Whether the data should be streamed
files (dict): The files to send to the server
timeout (float): The timeout, in seconds, for the request
obey_rate_limit (bool): Whether to obey 429 Too Many Request
responses. Defaults to True.
retry_transient_errors (bool): Whether to retry after 500, 502,
503, or 504 responses. Defaults
to False.
max_retries (int): Max retries after 429 or transient errors,
set to -1 to retry forever. Defaults to 10.
**kwargs: Extra options to send to the server (e.g. sudo)

Returns:
Expand DownExpand Up@@ -496,9 +508,10 @@ def http_request(
opts = self._get_session_opts(content_type="application/json")

verify = opts.pop("verify")
timeout = opts.pop("timeout")
opts_timeout = opts.pop("timeout")
# If timeout was passed into kwargs, allow it to override the default
timeout = kwargs.get("timeout", timeout)
if timeout is None:
timeout = opts_timeout

# We need to deal with json vs. data when uploading files
if files:
Expand DownExpand Up@@ -526,15 +539,7 @@ def http_request(
prepped.url, {}, streamed, verify, None
)

# obey the rate limit by default
obey_rate_limit = kwargs.get("obey_rate_limit", True)
# do not retry transient errors by default
retry_transient_errors = kwargs.get("retry_transient_errors", False)

# set max_retries to 10 by default, disable by setting it to -1
max_retries = kwargs.get("max_retries", 10)
cur_retries = 0

while True:
result = self.session.send(prepped, timeout=timeout, **settings)

Expand DownExpand Up@@ -821,6 +826,9 @@ def __init__(
self._query(url, query_data, **self._kwargs)
self._get_next = get_next

# Remove query_parameters from kwargs, which are saved via the `next` URL
self._kwargs.pop("query_parameters", None)

def _query(
self, url: str, query_data: Optional[Dict[str, Any]] = None, **kwargs: Any
) -> None:
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp