Rate limiter: fix datetime parser (fixes #5)
This commit is contained in:
parent
e2a18f8888
commit
d932256125
3
utils.py
3
utils.py
|
@ -6,6 +6,7 @@ import platform
|
|||
import contextlib
|
||||
from functools import wraps
|
||||
from datetime import datetime, timezone
|
||||
from dateutil.parser import parse as parsedate
|
||||
|
||||
def http_session_factory(headers={}, **kwargs):
|
||||
user_agent = (
|
||||
|
@ -73,7 +74,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 New Issue