From f5de2cd9a0aa1d24d19e63067cf761e2864373d7 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Thu, 8 Aug 2019 09:32:18 +0200 Subject: [PATCH] Fix logging bug on disconnect --- telethon/network/mtprotosender.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/telethon/network/mtprotosender.py b/telethon/network/mtprotosender.py index 6b5f6585..0da0ad69 100644 --- a/telethon/network/mtprotosender.py +++ b/telethon/network/mtprotosender.py @@ -258,7 +258,6 @@ class MTProtoSender: self._log.debug('Closing current connection...') await self._connection.disconnect() finally: - self._connection = None self._log.debug('Cancelling %d pending message(s)...', len(self._pending_state)) for state in self._pending_state.values(): if error and not state.future.done(): @@ -273,7 +272,9 @@ class MTProtoSender: recv_loop_handle=self._recv_loop_handle ) - self._log.info('Disconnection from %s complete!', self._connection) + self._log.info('Disconnection from %s complete!', self._connection) + self._connection = None + if self._disconnected and not self._disconnected.done(): if error: self._disconnected.set_exception(error)