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.
This commit is contained in:
Lonami Exo 2019-02-14 10:58:48 +01:00
parent 2e544270cd
commit d1c755809d
2 changed files with 5 additions and 2 deletions

View File

@ -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

View File

@ -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]