Handle ServiceUnavailable errors

#664
This commit is contained in:
Dan 2021-04-12 09:21:20 +02:00
parent b6f97ee924
commit 70ae12eb77

View File

@ -29,7 +29,7 @@ from pyrogram import __copyright__, __license__, __version__
from pyrogram import raw from pyrogram import raw
from pyrogram.connection import Connection from pyrogram.connection import Connection
from pyrogram.crypto import mtproto from pyrogram.crypto import mtproto
from pyrogram.errors import RPCError, InternalServerError, AuthKeyDuplicated, FloodWait from pyrogram.errors import RPCError, InternalServerError, AuthKeyDuplicated, FloodWait, ServiceUnavailable
from pyrogram.raw.all import layer from pyrogram.raw.all import layer
from pyrogram.raw.core import TLObject, MsgContainer, Int, FutureSalt, FutureSalts from pyrogram.raw.core import TLObject, MsgContainer, Int, FutureSalt, FutureSalts
from .internals import MsgId, MsgFactory from .internals import MsgId, MsgFactory
@ -432,7 +432,7 @@ class Session:
log.warning(f'[{self.client.session_name}] Sleeping for {amount}s (required by "{query}")') log.warning(f'[{self.client.session_name}] Sleeping for {amount}s (required by "{query}")')
await asyncio.sleep(amount) await asyncio.sleep(amount)
except (OSError, TimeoutError, InternalServerError) as e: except (OSError, TimeoutError, InternalServerError, ServiceUnavailable) as e:
if retries == 0: if retries == 0:
raise e from None raise e from None