From e2e1e3202e652f2d68bf5eb08d009c5b2e75bfcc Mon Sep 17 00:00:00 2001 From: z3z1ma Date: Tue, 21 May 2024 21:00:21 -0700 Subject: [PATCH] fix: move request client retry to correct central req method used in all codepaths --- dlt/sources/helpers/requests/retry.py | 2 +- tests/sources/helpers/test_requests.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dlt/sources/helpers/requests/retry.py b/dlt/sources/helpers/requests/retry.py index c9a813598f..3f9d7d559e 100644 --- a/dlt/sources/helpers/requests/retry.py +++ b/dlt/sources/helpers/requests/retry.py @@ -239,7 +239,7 @@ def _make_session(self) -> Session: session.mount("http://", self._adapter) session.mount("https://", self._adapter) retry = _make_retry(**self._retry_kwargs) - session.request = retry.wraps(session.request) # type: ignore[method-assign] + session.send = retry.wraps(session.send) # type: ignore[method-assign] return session @property diff --git a/tests/sources/helpers/test_requests.py b/tests/sources/helpers/test_requests.py index aefdf23e77..4acdeb9cbe 100644 --- a/tests/sources/helpers/test_requests.py +++ b/tests/sources/helpers/test_requests.py @@ -29,7 +29,7 @@ def mock_sleep() -> Iterator[mock.MagicMock]: def test_default_session_retry_settings() -> None: - retry: Retrying = Client().session.request.retry # type: ignore + retry: Retrying = Client().session.send.retry # type: ignore assert retry.stop.max_attempt_number == 5 # type: ignore assert isinstance(retry.retry, retry_any) retries = retry.retry.retries @@ -51,7 +51,7 @@ def custom_retry_cond(response, exception): respect_retry_after_header=False, ).session - retry: Retrying = session.request.retry # type: ignore + retry: Retrying = session.send.retry # type: ignore assert retry.stop.max_attempt_number == 14 # type: ignore assert isinstance(retry.retry, retry_any) retries = retry.retry.retries @@ -206,7 +206,7 @@ def test_init_default_client(existing_session: bool) -> None: session = default_client.session assert session.timeout == cfg["RUNTIME__REQUEST_TIMEOUT"] - retry = session.request.retry # type: ignore[attr-defined] + retry = session.send.retry # type: ignore[attr-defined] assert retry.wait.multiplier == cfg["RUNTIME__REQUEST_BACKOFF_FACTOR"] assert retry.stop.max_attempt_number == cfg["RUNTIME__REQUEST_MAX_ATTEMPTS"] assert retry.wait.max == cfg["RUNTIME__REQUEST_MAX_RETRY_DELAY"] @@ -226,7 +226,7 @@ def test_client_instance_with_config(existing_session: bool) -> None: session = client.session assert session.timeout == cfg["RUNTIME__REQUEST_TIMEOUT"] - retry = session.request.retry # type: ignore[attr-defined] + retry = session.send.retry # type: ignore[attr-defined] assert retry.wait.multiplier == cfg["RUNTIME__REQUEST_BACKOFF_FACTOR"] assert retry.stop.max_attempt_number == cfg["RUNTIME__REQUEST_MAX_ATTEMPTS"] assert retry.wait.max == cfg["RUNTIME__REQUEST_MAX_RETRY_DELAY"]