Handle OSError on MTProtoSender

This commit is contained in:
Lonami Exo 2018-06-14 16:16:11 +02:00
parent df1dfdf8ea
commit 4a9eb5b085

View File

@ -306,9 +306,10 @@ class MTProtoSender:
__log__.debug('Sending {} bytes...'.format(len(body))) __log__.debug('Sending {} bytes...'.format(len(body)))
await self._connection.send(body) await self._connection.send(body)
break break
# TODO Are there more exceptions besides timeout?
except asyncio.TimeoutError: except asyncio.TimeoutError:
continue continue
except OSError as e:
__log__.warning('OSError while sending %s', e)
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')
@ -341,12 +342,16 @@ class MTProtoSender:
# 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 ConnectionError as e:
__log__.info('Connection reset while receiving: {}'.format(e)) __log__.info('Connection reset while receiving %s', e)
asyncio.ensure_future(self._reconnect())
break
except OSError as e:
__log__.warning('OSError while receiving %s', e)
asyncio.ensure_future(self._reconnect()) asyncio.ensure_future(self._reconnect())
break break
# TODO Check salt, session_id and sequence_number # TODO Check salt, session_id and sequence_number
__log__.debug('Decoding packet of {} bytes...'.format(len(body))) __log__.debug('Decoding packet of %d bytes...', len(body))
try: try:
message = self.state.unpack_message(body) message = self.state.unpack_message(body)
except (BrokenAuthKeyError, BufferError) as e: except (BrokenAuthKeyError, BufferError) as e: