mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-23 01:46:35 +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()
|
||||
|
||||
messages = await self._send_queue.get()
|
||||
if messages == _reconnect_sentinel and self._reconnecting:
|
||||
if messages == _reconnect_sentinel:
|
||||
if self._reconnecting:
|
||||
break
|
||||
else:
|
||||
continue
|
||||
|
||||
if isinstance(messages, list):
|
||||
message = self.state.create_message(MessageContainer(messages))
|
||||
|
@ -364,11 +367,17 @@ class MTProtoSender:
|
|||
continue
|
||||
except asyncio.CancelledError:
|
||||
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)
|
||||
except:
|
||||
__log__.exception('Unhandled exception while sending')
|
||||
else:
|
||||
__log__.exception('Unhandled exception while receiving')
|
||||
await asyncio.sleep(1)
|
||||
|
||||
self._loop.create_task(self._reconnect())
|
||||
break
|
||||
else:
|
||||
# Remove the cancelled messages from pending
|
||||
__log__.info('Some futures were cancelled, aborted send')
|
||||
|
|
Loading…
Reference in New Issue
Block a user