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

Commit145870e

Browse files
nejchmax-wittig
authored andcommitted
feat(client): make retries configurable in GraphQL
1 parent8898c38 commit145870e

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

‎gitlab/client.py‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1287,6 +1287,9 @@ def __init__(
12871287
timeout:Optional[float]=None,
12881288
user_agent:str=gitlab.const.USER_AGENT,
12891289
fetch_schema_from_transport:bool=False,
1290+
max_retries:int=10,
1291+
obey_rate_limit:bool=True,
1292+
retry_transient_errors:bool=False,
12901293
)->None:
12911294
ifnot_GQL_INSTALLED:
12921295
raiseImportError(
@@ -1300,6 +1303,9 @@ def __init__(
13001303
self._url=f"{self._base_url}/api/graphql"
13011304
self._user_agent=user_agent
13021305
self._ssl_verify=ssl_verify
1306+
self._max_retries=max_retries
1307+
self._obey_rate_limit=obey_rate_limit
1308+
self._retry_transient_errors=retry_transient_errors
13031309

13041310
opts=self._get_client_opts()
13051311
self._http_client=clientorhttpx.Client(**opts)
@@ -1333,7 +1339,9 @@ def execute(
13331339
)->Any:
13341340
parsed_document=self._gql(request)
13351341
retry=utils.Retry(
1336-
max_retries=3,obey_rate_limit=True,retry_transient_errors=False
1342+
max_retries=self._max_retries,
1343+
obey_rate_limit=self._obey_rate_limit,
1344+
retry_transient_errors=self._retry_transient_errors,
13371345
)
13381346

13391347
whileTrue:

‎tests/unit/test_graphql.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,18 @@ def test_graphql_retries_on_429_response(
3535
gl_gql.execute("query {currentUser {id}}")
3636

3737

38-
deftest_graphql_raises_when_max_retries_exceeded(
39-
gl_gql:gitlab.GraphQL,respx_mock:respx.MockRouter
40-
):
38+
deftest_graphql_raises_when_max_retries_exceeded(respx_mock:respx.MockRouter):
4139
url="https://gitlab.example.com/api/graphql"
4240
responses= [
4341
httpx.Response(502),
4442
httpx.Response(502),
4543
httpx.Response(502),
46-
httpx.Response(502),
47-
httpx.Response(502),
4844
]
4945
respx_mock.post(url).mock(side_effect=responses)
46+
47+
gl_gql=gitlab.GraphQL(
48+
"https://gitlab.example.com",max_retries=1,retry_transient_errors=True
49+
)
5050
withpytest.raises(gitlab.GitlabHttpError):
5151
gl_gql.execute("query {currentUser {id}}")
5252

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp