From 7c37f32dc4f14d77dd39a099245f114b3ab16081 Mon Sep 17 00:00:00 2001 From: Goffi Date: Thu, 4 Nov 2021 18:27:36 +0100 Subject: [PATCH] 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. --- sat/core/xmpp.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sat/core/xmpp.py b/sat/core/xmpp.py index 46028ffa..1fddf577 100644 --- a/sat/core/xmpp.py +++ b/sat/core/xmpp.py @@ -302,7 +302,11 @@ class SatXMPPEntity: 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"""