mirror of
https://github.com/ioistired/pleroma-ebooks.git
synced 2024-11-20 02:14:52 +01:00
Rate limiter: fix datetime parser (fixes #5)
This commit is contained in:
parent
6523a28e11
commit
82320560a1
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 New Issue
Block a user