Skip to content

Commit

Permalink
fix: move request client retry to correct central req method used in …
Browse files Browse the repository at this point in the history
…all codepaths
  • Loading branch information
z3z1ma committed May 22, 2024
1 parent 64c9538 commit e2e1e32
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion dlt/sources/helpers/requests/retry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions tests/sources/helpers/test_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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"]
Expand All @@ -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"]

0 comments on commit e2e1e32

Please sign in to comment.