diff --git a/fauna/http/httpx_client.py b/fauna/http/httpx_client.py index 701a45ca..ca76141e 100644 --- a/fauna/http/httpx_client.py +++ b/fauna/http/httpx_client.py @@ -68,15 +68,27 @@ def request( except httpx.InvalidURL as e: raise ClientError("Invalid URL Format") from e + try: + return HTTPXResponse(self._send_with_retry(3, request)) + except (httpx.HTTPError, httpx.InvalidURL) as e: + raise NetworkError("Exception re-raised from HTTP request") from e + + def _send_with_retry( + self, + retryCount: int, + request: httpx.Request, + ) -> httpx.Response: try: response = self._c.send( request, stream=False, ) - except (httpx.HTTPError, httpx.InvalidURL) as e: - raise NetworkError("Exception re-raised from HTTP request") from e - - return HTTPXResponse(response) + return response + except httpx.TransportError as e: + if retryCount == 0: + raise e + else: + return self._send_with_retry(retryCount - 1, request) def stream( self,