Commit fbd65d79 authored by Philipp Hörist's avatar Philipp Hörist

Client: Don't create nbxmpp.Client() after cleanup()

parent dce40846
......@@ -77,6 +77,8 @@ def __init__(self, account):
self._ssl_errors = set()
self._destroyed = False
self.available_transports = {}
......@@ -120,6 +122,16 @@ def set_remove_account(self, value):
self._remove_account = value
def _create_client(self):
if self._destroyed:
# If we disable an account cleanup() is called and all
# modules are unregistered. Because disable_account() does not wait
# for the client to properly disconnect, handlers of the
# nbxmpp.Client() are emitted after we called cleanup().
# After nbxmpp.Client() disconnects and is destroyed we create a
# new instance with this method but modules.get_handlers() fails
# because modules are already unregistered.
# TODO: Make this nicer
return'Create new nbxmpp client')
self._client = NBXMPPClient(log_context=self._account)
self.connection = self._client
......@@ -518,6 +530,7 @@ def _disable_reconnect_timer(self):
self._reconnect_timer_source = None
def cleanup(self):
self._destroyed = True
def quit(self, kill_core):
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment