changeset 3698:a806dcad6bfc

core: don't callback `self.conn_deferred` if already called: if the connection has been lost (e.g. forced disconnection by server), `self.conn_deferred` may have already been called, thus this is now checked to avoid an exception.
author Goffi <goffi@goffi.org>
date Thu, 04 Nov 2021 18:27:36 +0100
parents 842b522d525e
children 2dab494e56fc
files sat/core/xmpp.py
diffstat 1 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/sat/core/xmpp.py	Thu Nov 04 18:13:55 2021 +0100
+++ b/sat/core/xmpp.py	Thu Nov 04 18:27:36 2021 +0100
@@ -302,7 +302,11 @@
         self.streamInitialized()
 
     def _finish_connection(self, __):
-        self.conn_deferred.callback(None)
+        if self.conn_deferred.called:
+            # can happen in case of forced disconnection by server
+            log.debug(f"{self} has already been connected")
+        else:
+            self.conn_deferred.callback(None)
 
     def streamInitialized(self):
         """Called after _authd"""