| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 8898c38 commit 145870e
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1287,6 +1287,9 @@ def __init__( | |||
| 1287 | 1287 | timeout: Optional[float] = None, | |
| 1288 | 1288 | user_agent: str = gitlab.const.USER_AGENT, | |
| 1289 | 1289 | fetch_schema_from_transport: bool = False, | |
| 1290 | + max_retries: int = 10, | ||
| 1291 | + obey_rate_limit: bool = True, | ||
| 1292 | + retry_transient_errors: bool = False, | ||
| 1290 | 1293 | ) -> None: | |
| 1291 | 1294 | if not _GQL_INSTALLED: | |
| 1292 | 1295 | raise ImportError( | |
@@ -1300,6 +1303,9 @@ def __init__( | |||
| 1300 | 1303 | self._url = f"{self._base_url}/api/graphql" | |
| 1301 | 1304 | self._user_agent = user_agent | |
| 1302 | 1305 | 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 | ||
| 1303 | 1309 | ||
| 1304 | 1310 | opts = self._get_client_opts() | |
| 1305 | 1311 | self._http_client = client or httpx.Client(**opts) | |
@@ -1333,7 +1339,9 @@ def execute( | |||
| 1333 | 1339 | ) -> Any: | |
| 1334 | 1340 | parsed_document = self._gql(request) | |
| 1335 | 1341 | 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, | ||
| 1337 | 1345 | ) | |
| 1338 | 1346 | ||
| 1339 | 1347 | while True: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -35,18 +35,18 @@ def test_graphql_retries_on_429_response( | |||
| 35 | 35 | gl_gql.execute("query {currentUser {id}}") | |
| 36 | 36 | ||
| 37 | 37 | ||
| 38 | - def test_graphql_raises_when_max_retries_exceeded( | ||
| 39 | - gl_gql: gitlab.GraphQL, respx_mock: respx.MockRouter | ||
| 40 | - ): | ||
| 38 | + def test_graphql_raises_when_max_retries_exceeded(respx_mock: respx.MockRouter): | ||
| 41 | 39 | url = "https://gitlab.example.com/api/graphql" | |
| 42 | 40 | responses = [ | |
| 43 | 41 | httpx.Response(502), | |
| 44 | 42 | httpx.Response(502), | |
| 45 | 43 | httpx.Response(502), | |
| 46 | - httpx.Response(502), | ||
| 47 | - httpx.Response(502), | ||
| 48 | 44 | ] | |
| 49 | 45 | 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 | + ) | ||
| 50 | 50 | with pytest.raises(gitlab.GitlabHttpError): | |
| 51 | 51 | gl_gql.execute("query {currentUser {id}}") | |
| 52 | 52 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments