comparison 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
comparison
equal deleted inserted replaced
3697:842b522d525e 3698:a806dcad6bfc
300 super(SatXMPPEntity, self)._authd(xmlstream) 300 super(SatXMPPEntity, self)._authd(xmlstream)
301 log.debug(_("{profile} identified").format(profile=self.profile)) 301 log.debug(_("{profile} identified").format(profile=self.profile))
302 self.streamInitialized() 302 self.streamInitialized()
303 303
304 def _finish_connection(self, __): 304 def _finish_connection(self, __):
305 self.conn_deferred.callback(None) 305 if self.conn_deferred.called:
306 # can happen in case of forced disconnection by server
307 log.debug(f"{self} has already been connected")
308 else:
309 self.conn_deferred.callback(None)
306 310
307 def streamInitialized(self): 311 def streamInitialized(self):
308 """Called after _authd""" 312 """Called after _authd"""
309 log.debug(_("XML stream is initialized")) 313 log.debug(_("XML stream is initialized"))
310 if not self.host_app.trigger.point("xml_init", self): 314 if not self.host_app.trigger.point("xml_init", self):