Skip to content

Commit 2dc1c7e

Browse files
authored
Don't compute time_to_sleep 2 times. (#51)
If jitter is configured it will produce randomness . This was done properly in sleep() so I can only assume this was an oversight.
1 parent cee931d commit 2dc1c7e

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

httpx_retries/retry.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ async def asleep(self, response: Union[httpx.Response, Exception]) -> None:
238238
"""
239239
time_to_sleep = self._calculate_sleep(response.headers if isinstance(response, httpx.Response) else {})
240240
logger.debug("asleep seconds=%s", time_to_sleep)
241-
await asyncio.sleep(self._calculate_sleep(response.headers if isinstance(response, httpx.Response) else {}))
241+
await asyncio.sleep(time_to_sleep)
242242

243243
def increment(self) -> "Retry":
244244
"""Return a new Retry instance with the attempt count incremented."""

0 commit comments

Comments
 (0)