Merge branch 'handle-503-timeout'
This commit is contained in:
commit
54350dc943
@ -96,6 +96,7 @@ def start():
|
||||
|
||||
sub_class = caml(re.sub(r"_X", "_", error_id))
|
||||
sub_class = re.sub(r"^2", "Two", sub_class)
|
||||
sub_class = re.sub(r" ", "", sub_class)
|
||||
|
||||
f_all.write(" \"{}\": \"{}\",\n".format(error_id, sub_class))
|
||||
|
||||
|
@ -41,3 +41,4 @@ VOLUME_LOC_NOT_FOUND Telegram is having internal problems. Please try again late
|
||||
WORKER_BUSY_TOO_LONG_RETRY Server workers are too busy right now due to Telegram having internal problems. Please try again later
|
||||
WP_ID_GENERATE_FAILED Telegram is having internal problems. Please try again later
|
||||
GROUPCALL_ADD_PARTICIPANTS_FAILED Failure while adding voice chat member due to Telegram having internal problems. Please try again later
|
||||
No workers running The Telegram server is restarting its workers. Try again later.
|
|
2
compiler/errors/source/503_SERVICE_UNAVAILABLE.tsv
Normal file
2
compiler/errors/source/503_SERVICE_UNAVAILABLE.tsv
Normal file
@ -0,0 +1,2 @@
|
||||
id message
|
||||
Timeout Telegram is having internal problems. Please try again later.
|
|
@ -32,8 +32,15 @@ class RPCError(Exception):
|
||||
NAME = None
|
||||
MESSAGE = "{x}"
|
||||
|
||||
def __init__(self, x: Union[int, raw.types.RpcError] = None, rpc_name: str = None, is_unknown: bool = False):
|
||||
super().__init__("[{} {}]: {} {}".format(
|
||||
def __init__(
|
||||
self,
|
||||
x: Union[int, str, raw.types.RpcError] = None,
|
||||
rpc_name: str = None,
|
||||
is_unknown: bool = False,
|
||||
is_signed: bool = False
|
||||
):
|
||||
super().__init__("[{}{} {}]: {} {}".format(
|
||||
"-" if is_signed else "",
|
||||
self.CODE,
|
||||
self.ID or self.NAME,
|
||||
self.MESSAGE.format(x=x),
|
||||
@ -52,14 +59,19 @@ class RPCError(Exception):
|
||||
@staticmethod
|
||||
def raise_it(rpc_error: "raw.types.RpcError", rpc_type: Type[TLObject]):
|
||||
error_code = rpc_error.error_code
|
||||
is_signed = error_code < 0
|
||||
error_message = rpc_error.error_message
|
||||
rpc_name = ".".join(rpc_type.QUALNAME.split(".")[1:])
|
||||
|
||||
if is_signed:
|
||||
error_code = -error_code
|
||||
|
||||
if error_code not in exceptions:
|
||||
raise UnknownError(
|
||||
x=f"[{error_code} {error_message}]",
|
||||
rpc_name=rpc_name,
|
||||
is_unknown=True
|
||||
is_unknown=True,
|
||||
is_signed=is_signed
|
||||
)
|
||||
|
||||
error_id = re.sub(r"_\d+", "_X", error_message)
|
||||
@ -70,7 +82,8 @@ class RPCError(Exception):
|
||||
exceptions[error_code]["_"]
|
||||
)(x=f"[{error_code} {error_message}]",
|
||||
rpc_name=rpc_name,
|
||||
is_unknown=True)
|
||||
is_unknown=True,
|
||||
is_signed=is_signed)
|
||||
|
||||
x = re.search(r"_(\d+)", error_message)
|
||||
x = x.group(1) if x is not None else x
|
||||
@ -80,7 +93,8 @@ class RPCError(Exception):
|
||||
exceptions[error_code][error_id]
|
||||
)(x=x,
|
||||
rpc_name=rpc_name,
|
||||
is_unknown=False)
|
||||
is_unknown=False,
|
||||
is_signed=is_signed)
|
||||
|
||||
|
||||
class UnknownError(RPCError):
|
||||
|
@ -29,7 +29,7 @@ from pyrogram import __copyright__, __license__, __version__
|
||||
from pyrogram import raw
|
||||
from pyrogram.connection import Connection
|
||||
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.core import TLObject, MsgContainer, Int, FutureSalt, FutureSalts
|
||||
from .internals import MsgId, MsgFactory
|
||||
@ -433,7 +433,7 @@ class Session:
|
||||
log.warning(f'[{self.client.session_name}] Sleeping for {amount}s (required by "{query}")')
|
||||
|
||||
await asyncio.sleep(amount)
|
||||
except (OSError, TimeoutError, InternalServerError) as e:
|
||||
except (OSError, TimeoutError, InternalServerError, ServiceUnavailable) as e:
|
||||
if retries == 0:
|
||||
raise e from None
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user