mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-06-18 11:06:39 +00:00
Add more logging in the MTProtoSender
This commit is contained in:
parent
e36aff51dd
commit
94d6c339c4
@ -352,6 +352,9 @@ class MTProtoSender:
|
|||||||
continue
|
continue
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
__log__.warning('OSError while sending %s', e)
|
__log__.warning('OSError while sending %s', e)
|
||||||
|
except:
|
||||||
|
__log__.exception('Unhandled exception while sending')
|
||||||
|
await asyncio.sleep(1)
|
||||||
else:
|
else:
|
||||||
# Remove the cancelled messages from pending
|
# Remove the cancelled messages from pending
|
||||||
__log__.info('Some futures were cancelled, aborted send')
|
__log__.info('Some futures were cancelled, aborted send')
|
||||||
@ -383,12 +386,15 @@ class MTProtoSender:
|
|||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
# TODO If nothing is received for a minute, send a request
|
# TODO If nothing is received for a minute, send a request
|
||||||
continue
|
continue
|
||||||
except ConnectionError as e:
|
except Exception as e:
|
||||||
__log__.info('Connection reset while receiving %s', e)
|
if isinstance(e, ConnectionError):
|
||||||
self._loop.create_task(self._reconnect())
|
__log__.info('Connection reset while receiving %s', e)
|
||||||
break
|
elif isinstance(e, OSError):
|
||||||
except OSError as e:
|
__log__.warning('OSError while receiving %s', e)
|
||||||
__log__.warning('OSError while receiving %s', e)
|
else:
|
||||||
|
__log__.exception('Unhandled exception while receiving')
|
||||||
|
await asyncio.sleep(1)
|
||||||
|
|
||||||
self._loop.create_task(self._reconnect())
|
self._loop.create_task(self._reconnect())
|
||||||
break
|
break
|
||||||
|
|
||||||
@ -414,14 +420,23 @@ class MTProtoSender:
|
|||||||
# A step while decoding had the incorrect data. This message
|
# A step while decoding had the incorrect data. This message
|
||||||
# should not be considered safe and it should be ignored.
|
# should not be considered safe and it should be ignored.
|
||||||
__log__.warning('Security error while unpacking a '
|
__log__.warning('Security error while unpacking a '
|
||||||
'received message:'.format(e))
|
'received message: {}'.format(e))
|
||||||
continue
|
continue
|
||||||
except TypeNotFoundError as e:
|
except TypeNotFoundError as e:
|
||||||
# The payload inside the message was not a known TLObject.
|
# The payload inside the message was not a known TLObject.
|
||||||
__log__.info('Server replied with an unknown type {:08x}: {!r}'
|
__log__.info('Server replied with an unknown type {:08x}: {!r}'
|
||||||
.format(e.invalid_constructor_id, e.remaining))
|
.format(e.invalid_constructor_id, e.remaining))
|
||||||
|
continue
|
||||||
|
except:
|
||||||
|
__log__.exception('Unhandled exception while unpacking')
|
||||||
|
await asyncio.sleep(1)
|
||||||
else:
|
else:
|
||||||
await self._process_message(message)
|
try:
|
||||||
|
await self._process_message(message)
|
||||||
|
except:
|
||||||
|
__log__.exception('Unhandled exception while '
|
||||||
|
'processing %s', message)
|
||||||
|
await asyncio.sleep(1)
|
||||||
|
|
||||||
# Response Handlers
|
# Response Handlers
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user