Rate limiter: fix datetime parser (fixes #5)
This commit is contained in:
parent
6523a28e11
commit
82320560a1
1 changed files with 2 additions and 1 deletions
3
utils.py
3
utils.py
|
@ -4,6 +4,7 @@ import anyio
|
|||
import contextlib
|
||||
from functools import wraps
|
||||
from datetime import datetime, timezone
|
||||
from dateutil.parser import parse as parsedate
|
||||
|
||||
def as_corofunc(f):
|
||||
@wraps(f)
|
||||
|
@ -60,7 +61,7 @@ class _RateLimitContextManager(contextlib.AbstractAsyncContextManager):
|
|||
if resp.headers.get('X-RateLimit-Remaining') not in {'0', '1'}:
|
||||
return resp
|
||||
|
||||
await sleep_until(datetime.fromisoformat(resp.headers['X-RateLimit-Reset']))
|
||||
await sleep_until(parsedate(resp.headers['X-RateLimit-Reset']))
|
||||
await self._request_cm.__aexit__(*(None,)*3)
|
||||
return await self.__aenter__()
|
||||
|
||||
|
|
Loading…
Reference in a new issue