mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-06-17 18:46:40 +00:00
Change the way flood_sleep_threshold behaves
This commit is contained in:
parent
183d07ff25
commit
31a4d21c41
@ -53,7 +53,7 @@ class Config:
|
|||||||
lang_code: str = "en"
|
lang_code: str = "en"
|
||||||
catch_up: bool = False
|
catch_up: bool = False
|
||||||
datacenter: Optional[DataCenter] = None
|
datacenter: Optional[DataCenter] = None
|
||||||
flood_sleep_threshold: Optional[int] = 60
|
flood_sleep_threshold: int = 60
|
||||||
update_queue_limit: Optional[int] = None
|
update_queue_limit: Optional[int] = None
|
||||||
|
|
||||||
|
|
||||||
@ -245,8 +245,7 @@ async def invoke_request(
|
|||||||
lock: asyncio.Lock,
|
lock: asyncio.Lock,
|
||||||
request: Request[Return],
|
request: Request[Return],
|
||||||
) -> Return:
|
) -> Return:
|
||||||
slept_flood = False
|
sleep_thresh = client._config.flood_sleep_threshold
|
||||||
sleep_thresh = client._config.flood_sleep_threshold or 0
|
|
||||||
rx = sender.enqueue(request)
|
rx = sender.enqueue(request)
|
||||||
while True:
|
while True:
|
||||||
while not rx.done():
|
while not rx.done():
|
||||||
@ -255,14 +254,9 @@ async def invoke_request(
|
|||||||
response = rx.result()
|
response = rx.result()
|
||||||
break
|
break
|
||||||
except RpcError as e:
|
except RpcError as e:
|
||||||
if (
|
if e.code == 420 and e.value is not None and e.value < sleep_thresh:
|
||||||
e.code == 420
|
|
||||||
and e.value is not None
|
|
||||||
and not slept_flood
|
|
||||||
and e.value < sleep_thresh
|
|
||||||
):
|
|
||||||
await asyncio.sleep(e.value)
|
await asyncio.sleep(e.value)
|
||||||
slept_flood = True
|
sleep_thresh -= e.value
|
||||||
rx = sender.enqueue(request)
|
rx = sender.enqueue(request)
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user