mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-05 20:50:22 +03:00
Fix sleeps
This commit is contained in:
parent
25b220b4bd
commit
e1f8807d83
|
@ -242,8 +242,8 @@ class MessageMethods(UploadMethods, MessageParseMethods):
|
||||||
else:
|
else:
|
||||||
request.max_date = last_message.date
|
request.max_date = last_message.date
|
||||||
|
|
||||||
asyncio.sleep(
|
time.sleep(
|
||||||
max(wait_time - (time.time() - start), 0), loop=self._loop)
|
max(wait_time - (time.time() - start), 0))
|
||||||
|
|
||||||
def get_messages(self, *args, **kwargs):
|
def get_messages(self, *args, **kwargs):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import asyncio
|
import concurrent.futures
|
||||||
import inspect
|
|
||||||
import itertools
|
import itertools
|
||||||
import logging
|
import logging
|
||||||
import random
|
import random
|
||||||
|
@ -188,11 +187,9 @@ class UpdateMethods(UserMethods):
|
||||||
rnd = lambda: random.randrange(-2**63, 2**63)
|
rnd = lambda: random.randrange(-2**63, 2**63)
|
||||||
while self.is_connected():
|
while self.is_connected():
|
||||||
try:
|
try:
|
||||||
asyncio.wait_for(
|
concurrent.futures.wait([self.disconnected], timeout=60)
|
||||||
self.disconnected, timeout=60, loop=self._loop
|
|
||||||
)
|
|
||||||
continue # We actually just want to act upon timeout
|
continue # We actually just want to act upon timeout
|
||||||
except asyncio.TimeoutError:
|
except concurrent.futures.TimeoutError:
|
||||||
pass
|
pass
|
||||||
except:
|
except:
|
||||||
continue # Any disconnected exception should be ignored
|
continue # Any disconnected exception should be ignored
|
||||||
|
|
|
@ -39,7 +39,7 @@ class UserMethods(TelegramBaseClient):
|
||||||
except (errors.FloodWaitError, errors.FloodTestPhoneWaitError) as e:
|
except (errors.FloodWaitError, errors.FloodTestPhoneWaitError) as e:
|
||||||
if e.seconds <= self.flood_sleep_threshold:
|
if e.seconds <= self.flood_sleep_threshold:
|
||||||
__log__.info('Sleeping for %ds on flood wait', e.seconds)
|
__log__.info('Sleeping for %ds on flood wait', e.seconds)
|
||||||
asyncio.sleep(e.seconds, loop=self._loop)
|
time.sleep(e.seconds)
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
except (errors.PhoneMigrateError, errors.NetworkMigrateError,
|
except (errors.PhoneMigrateError, errors.NetworkMigrateError,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user