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

Commitcfc42d2

Browse files
authored
Merge pull request#1392 from bbatliner/patch-1
Improvements to HTTP requests
2 parents4f79dff +b9ecc9a commitcfc42d2

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

‎gitlab/client.py

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,10 @@ def http_request(
451451
post_data:Optional[Dict[str,Any]]=None,
452452
streamed:bool=False,
453453
files:Optional[Dict[str,Any]]=None,
454+
timeout:Optional[float]=None,
455+
obey_rate_limit:bool=True,
456+
retry_transient_errors:bool=False,
457+
max_retries:int=10,
454458
**kwargs:Any,
455459
)->requests.Response:
456460
"""Make an HTTP request to the Gitlab server.
@@ -465,6 +469,14 @@ def http_request(
465469
json)
466470
streamed (bool): Whether the data should be streamed
467471
files (dict): The files to send to the server
472+
timeout (float): The timeout, in seconds, for the request
473+
obey_rate_limit (bool): Whether to obey 429 Too Many Request
474+
responses. Defaults to True.
475+
retry_transient_errors (bool): Whether to retry after 500, 502,
476+
503, or 504 responses. Defaults
477+
to False.
478+
max_retries (int): Max retries after 429 or transient errors,
479+
set to -1 to retry forever. Defaults to 10.
468480
**kwargs: Extra options to send to the server (e.g. sudo)
469481
470482
Returns:
@@ -496,9 +508,10 @@ def http_request(
496508
opts=self._get_session_opts(content_type="application/json")
497509

498510
verify=opts.pop("verify")
499-
timeout=opts.pop("timeout")
511+
opts_timeout=opts.pop("timeout")
500512
# If timeout was passed into kwargs, allow it to override the default
501-
timeout=kwargs.get("timeout",timeout)
513+
iftimeoutisNone:
514+
timeout=opts_timeout
502515

503516
# We need to deal with json vs. data when uploading files
504517
iffiles:
@@ -532,15 +545,7 @@ def http_request(
532545
prepped.url, {},streamed,verify,None
533546
)
534547

535-
# obey the rate limit by default
536-
obey_rate_limit=kwargs.get("obey_rate_limit",True)
537-
# do not retry transient errors by default
538-
retry_transient_errors=kwargs.get("retry_transient_errors",False)
539-
540-
# set max_retries to 10 by default, disable by setting it to -1
541-
max_retries=kwargs.get("max_retries",10)
542548
cur_retries=0
543-
544549
whileTrue:
545550
result=self.session.send(prepped,timeout=timeout,**settings)
546551

@@ -827,6 +832,9 @@ def __init__(
827832
self._query(url,query_data,**self._kwargs)
828833
self._get_next=get_next
829834

835+
# Remove query_parameters from kwargs, which are saved via the `next` URL
836+
self._kwargs.pop("query_parameters",None)
837+
830838
def_query(
831839
self,url:str,query_data:Optional[Dict[str,Any]]=None,**kwargs:Any
832840
)->None:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp