Loading gitlab/client.py +9 −1 Original line number Diff line number Diff line Loading @@ -1287,6 +1287,9 @@ class GraphQL: timeout: Optional[float] = None, user_agent: str = gitlab.const.USER_AGENT, fetch_schema_from_transport: bool = False, max_retries: int = 10, obey_rate_limit: bool = True, retry_transient_errors: bool = False, ) -> None: if not _GQL_INSTALLED: raise ImportError( Loading @@ -1300,6 +1303,9 @@ class GraphQL: self._url = f"{self._base_url}/api/graphql" self._user_agent = user_agent self._ssl_verify = ssl_verify self._max_retries = max_retries self._obey_rate_limit = obey_rate_limit self._retry_transient_errors = retry_transient_errors opts = self._get_client_opts() self._http_client = client or httpx.Client(**opts) Loading Loading @@ -1333,7 +1339,9 @@ class GraphQL: ) -> Any: parsed_document = self._gql(request) retry = utils.Retry( max_retries=3, obey_rate_limit=True, retry_transient_errors=False max_retries=self._max_retries, obey_rate_limit=self._obey_rate_limit, retry_transient_errors=self._retry_transient_errors, ) while True: Loading tests/unit/test_graphql.py +5 −5 Original line number Diff line number Diff line Loading @@ -35,18 +35,18 @@ def test_graphql_retries_on_429_response( gl_gql.execute("query {currentUser {id}}") def test_graphql_raises_when_max_retries_exceeded( gl_gql: gitlab.GraphQL, respx_mock: respx.MockRouter ): def test_graphql_raises_when_max_retries_exceeded(respx_mock: respx.MockRouter): url = "https://gitlab.example.com/api/graphql" responses = [ httpx.Response(502), httpx.Response(502), httpx.Response(502), httpx.Response(502), httpx.Response(502), ] respx_mock.post(url).mock(side_effect=responses) gl_gql = gitlab.GraphQL( "https://gitlab.example.com", max_retries=1, retry_transient_errors=True ) with pytest.raises(gitlab.GitlabHttpError): gl_gql.execute("query {currentUser {id}}") Loading Loading
gitlab/client.py +9 −1 Original line number Diff line number Diff line Loading @@ -1287,6 +1287,9 @@ class GraphQL: timeout: Optional[float] = None, user_agent: str = gitlab.const.USER_AGENT, fetch_schema_from_transport: bool = False, max_retries: int = 10, obey_rate_limit: bool = True, retry_transient_errors: bool = False, ) -> None: if not _GQL_INSTALLED: raise ImportError( Loading @@ -1300,6 +1303,9 @@ class GraphQL: self._url = f"{self._base_url}/api/graphql" self._user_agent = user_agent self._ssl_verify = ssl_verify self._max_retries = max_retries self._obey_rate_limit = obey_rate_limit self._retry_transient_errors = retry_transient_errors opts = self._get_client_opts() self._http_client = client or httpx.Client(**opts) Loading Loading @@ -1333,7 +1339,9 @@ class GraphQL: ) -> Any: parsed_document = self._gql(request) retry = utils.Retry( max_retries=3, obey_rate_limit=True, retry_transient_errors=False max_retries=self._max_retries, obey_rate_limit=self._obey_rate_limit, retry_transient_errors=self._retry_transient_errors, ) while True: Loading
tests/unit/test_graphql.py +5 −5 Original line number Diff line number Diff line Loading @@ -35,18 +35,18 @@ def test_graphql_retries_on_429_response( gl_gql.execute("query {currentUser {id}}") def test_graphql_raises_when_max_retries_exceeded( gl_gql: gitlab.GraphQL, respx_mock: respx.MockRouter ): def test_graphql_raises_when_max_retries_exceeded(respx_mock: respx.MockRouter): url = "https://gitlab.example.com/api/graphql" responses = [ httpx.Response(502), httpx.Response(502), httpx.Response(502), httpx.Response(502), httpx.Response(502), ] respx_mock.post(url).mock(side_effect=responses) gl_gql = gitlab.GraphQL( "https://gitlab.example.com", max_retries=1, retry_transient_errors=True ) with pytest.raises(gitlab.GitlabHttpError): gl_gql.execute("query {currentUser {id}}") Loading