Skip to content

Commit 2e8c6ef

Browse files
authored
Merge pull request #104 from praw-dev/4291second
Sleep for a full second when rate limit is expired with no remaining …
2 parents 68a325f + 87e519e commit 2e8c6ef

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

CHANGES.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ asyncprawcore follows `semantic versioning <https://semver.org/>`_.
66
Unreleased
77
----------
88

9+
**Fixed**
10+
11+
- Increase half-second delay introduced in ``3.0.0`` to a full second delay.
12+
913
3.0.0 (2025/08/02)
1014
------------------
1115

asyncprawcore/rate_limit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def update(self, response_headers: Mapping[str, str]):
9393

9494
if self.remaining <= 0:
9595
self.next_request_timestamp_ns = now_ns + max(
96-
NANOSECONDS / 2, seconds_to_reset * NANOSECONDS
96+
NANOSECONDS, seconds_to_reset * NANOSECONDS
9797
)
9898
return
9999

tests/unit/test_rate_limit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def test_update__delay_full_time_with_zero_remaining_and_no_sleep_time(
121121
rate_limiter.update(self._headers(0, 100, 0))
122122
assert rate_limiter.remaining == 0
123123
assert rate_limiter.used == 100
124-
assert rate_limiter.next_request_timestamp_ns == 37.5 * NANOSECONDS
124+
assert rate_limiter.next_request_timestamp_ns == 38 * NANOSECONDS
125125

126126
def test_update__no_change_without_headers(self, rate_limiter):
127127
prev = copy(rate_limiter)

0 commit comments

Comments
 (0)