mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-06-06 06:33:10 +03:00
Fix reconnect sentinel when not reconnecting in send_loop
It would cause issues with the debug logs, since it assumes it's a TLMessage, which have an .obj attribute. Second, the send_loop is also smarter regarding reconnects (since OSError often occur due to not being connected at all, namely ConnectionResetError).
This commit is contained in:
parent
c8ee0bdca9
commit
4ab5c7d92d
|
@ -338,8 +338,11 @@ class MTProtoSender:
|
||||||
self._pending_ack.clear()
|
self._pending_ack.clear()
|
||||||
|
|
||||||
messages = await self._send_queue.get()
|
messages = await self._send_queue.get()
|
||||||
if messages == _reconnect_sentinel and self._reconnecting:
|
if messages == _reconnect_sentinel:
|
||||||
|
if self._reconnecting:
|
||||||
break
|
break
|
||||||
|
else:
|
||||||
|
continue
|
||||||
|
|
||||||
if isinstance(messages, list):
|
if isinstance(messages, list):
|
||||||
message = self.state.create_message(MessageContainer(messages))
|
message = self.state.create_message(MessageContainer(messages))
|
||||||
|
@ -364,11 +367,17 @@ class MTProtoSender:
|
||||||
continue
|
continue
|
||||||
except asyncio.CancelledError:
|
except asyncio.CancelledError:
|
||||||
return
|
return
|
||||||
except OSError as e:
|
except Exception as e:
|
||||||
|
if isinstance(e, ConnectionError):
|
||||||
|
__log__.info('Connection reset while sending %s', e)
|
||||||
|
elif isinstance(e, OSError):
|
||||||
__log__.warning('OSError while sending %s', e)
|
__log__.warning('OSError while sending %s', e)
|
||||||
except:
|
else:
|
||||||
__log__.exception('Unhandled exception while sending')
|
__log__.exception('Unhandled exception while receiving')
|
||||||
await asyncio.sleep(1)
|
await asyncio.sleep(1)
|
||||||
|
|
||||||
|
self._loop.create_task(self._reconnect())
|
||||||
|
break
|
||||||
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')
|
||||||
|
|
Loading…
Reference in New Issue
Block a user