mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-22 09:26:37 +03:00
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.
This commit is contained in:
parent
308adc4192
commit
14bb158c8b
|
@ -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())
|
||||
|
|
Loading…
Reference in New Issue
Block a user