mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-10 19:46:36 +03:00
Faster iter_messages by sleeping only as much as needed
This commit is contained in:
parent
ea404c5477
commit
387a255221
|
@ -1111,6 +1111,7 @@ class TelegramClient(TelegramBareClient):
|
|||
have = 0
|
||||
batch_size = min(max(batch_size, 1), 100)
|
||||
while have < limit:
|
||||
start = time.time()
|
||||
# Telegram has a hard limit of 100
|
||||
request.limit = min(limit - have, batch_size)
|
||||
r = self(request)
|
||||
|
@ -1157,7 +1158,7 @@ class TelegramClient(TelegramBareClient):
|
|||
else:
|
||||
request.max_date = r.messages[-1].date
|
||||
|
||||
time.sleep(wait_time)
|
||||
time.sleep(max(wait_time - (time.time() - start), 0))
|
||||
|
||||
def get_messages(self, *args, **kwargs):
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue
Block a user