From d1c755809da3929a93b3dfd2f365aa870668b51a Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Thu, 14 Feb 2019 10:58:48 +0100 Subject: [PATCH] Except RpcMcgetFailError as call fail and sleep on server errors This one in particular may happen when iterating over messages, perhaps more likely to happen if the group was created in a different data center. A small sleep of a few seconds also greatly increases the chances of the error going away. --- telethon/client/auth.py | 2 +- telethon/client/users.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/telethon/client/auth.py b/telethon/client/auth.py index 57aabe0c..fab9d41d 100644 --- a/telethon/client/auth.py +++ b/telethon/client/auth.py @@ -233,7 +233,7 @@ class AuthMethods(MessageParseMethods, UserMethods): phone_hash = phone_hash or self._phone_code_hash.get(phone, None) if not phone_hash: - raise ValueError('You also need to provide a phone_hash.') + raise ValueError('You also need to provide a phone_code_hash.') return phone, phone_hash diff --git a/telethon/client/users.py b/telethon/client/users.py index 1779647e..2b0cc220 100644 --- a/telethon/client/users.py +++ b/telethon/client/users.py @@ -60,10 +60,13 @@ class UserMethods(TelegramBaseClient): result = await future self.session.process_entities(result) return result - except (errors.ServerError, errors.RpcCallFailError) as e: + except (errors.ServerError, errors.RpcCallFailError, + errors.RpcMcgetFailError) as e: self._log[__name__].warning( 'Telegram is having internal issues %s: %s', e.__class__.__name__, e) + + await asyncio.sleep(2) except (errors.FloodWaitError, errors.FloodTestPhoneWaitError) as e: if utils.is_list_like(request): request = request[request_index]