diff sat/core/xmpp.py @ 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 01c23359b915
children 09f5ac48ffe3 e3dddf65fa88
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"""