From 14bb158c8b585d9fe43466d4f93e44bda77bb364 Mon Sep 17 00:00:00 2001 From: LiemCH Date: Mon, 10 Oct 2016 13:45:56 +0700 Subject: [PATCH] Update mtproto_sender.py Raise error handle_rpc_result will corrupt session file. I add some annonying error and change raise to print for further report/investigation. You can implement logging if you wish. --- telethon/network/mtproto_sender.py | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/telethon/network/mtproto_sender.py b/telethon/network/mtproto_sender.py index 309fe5bf..645cc07b 100755 --- a/telethon/network/mtproto_sender.py +++ b/telethon/network/mtproto_sender.py @@ -283,19 +283,32 @@ class MtProtoSender: raise ValueError('The previously sent request must be resent. ' 'However, no request was previously sent (called from updates thread).') request.confirm_received = False - - if error.message.startswith('FLOOD_WAIT_'): + + if error.message.startswith('RANDOM_ID_DUPLICATE'): + # This error is unknown code 500, I cant reproduce whats is cause it. + # but will follow by another confirmation message, so we set to True + print(error.message) + request.confirm_received = True + + elif error.message.startswith('FLOOD_WAIT_'): print('Should wait {}s. Sleeping until then.'.format(error.additional_data)) sleep(error.additional_data) elif error.message.startswith('PHONE_MIGRATE_'): - raise InvalidDCError(error.additional_data) + # we just print error for further investigation, + # then raise error that will corrupt session file. + print(error.additional_data) else: - raise error + # printing error.message is better than raise error + # because it will corrupt session + print(error.message) else: if not request: - raise ValueError('Cannot receive a request from inside an RPC result from the updates thread.') + # Again sometimes, event the we already receive reply request + # Server send another same reply. + # So We ignore it and continue on updates thread + print('Cannot receive a request from inside an RPC result from the updates thread.') if inner_code == 0x3072cfa1: # GZip packed unpacked_data = gzip.decompress(reader.tgread_bytes())