mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-26 11:23:46 +03:00
Shield self.disconnected and log RpcCallFail
This commit is contained in:
parent
ee7a44d447
commit
efc48ee3b0
|
@ -177,7 +177,11 @@ 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:
|
||||||
await asyncio.wait_for(self.disconnected, timeout=60)
|
await asyncio.wait_for(
|
||||||
|
asyncio.shield(self.disconnected, loop=self._loop),
|
||||||
|
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 asyncio.TimeoutError:
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
import itertools
|
import itertools
|
||||||
|
import logging
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from .telegrambaseclient import TelegramBaseClient
|
from .telegrambaseclient import TelegramBaseClient
|
||||||
from .. import errors, utils
|
from .. import errors, utils
|
||||||
from ..tl import TLObject, TLRequest, types, functions
|
from ..tl import TLObject, TLRequest, types, functions
|
||||||
|
|
||||||
|
__log__ = logging.getLogger(__name__)
|
||||||
_NOT_A_REQUEST = TypeError('You can only invoke requests, not types!')
|
_NOT_A_REQUEST = TypeError('You can only invoke requests, not types!')
|
||||||
|
|
||||||
|
|
||||||
|
@ -28,10 +29,12 @@ class UserMethods(TelegramBaseClient):
|
||||||
return results
|
return results
|
||||||
else:
|
else:
|
||||||
return await future
|
return await future
|
||||||
except (errors.ServerError, errors.RpcCallFailError):
|
except (errors.ServerError, errors.RpcCallFailError) as e:
|
||||||
pass
|
__log__.warning('Telegram is having internal issues %s: %s',
|
||||||
|
e.__class__.__name__, e)
|
||||||
except (errors.FloodWaitError, errors.FloodTestPhoneWaitError) as e:
|
except (errors.FloodWaitError, errors.FloodTestPhoneWaitError) as e:
|
||||||
if e.seconds <= self.session.flood_sleep_threshold:
|
if e.seconds <= self.session.flood_sleep_threshold:
|
||||||
|
__log__.info('Sleeping for %ds on flood wait', e.seconds)
|
||||||
await asyncio.sleep(e.seconds, loop=self._loop)
|
await asyncio.sleep(e.seconds, loop=self._loop)
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
|
|
Loading…
Reference in New Issue
Block a user