Skip to content
Snippets Groups Projects
Commit fbd65d79 authored by Philipp Hörist's avatar Philipp Hörist
Browse files

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

parent dce40846
No related branches found
No related tags found
No related merge requests found
......@@ -77,6 +77,8 @@ def __init__(self, account):
self._ssl_errors = set()
self._destroyed = False
self.available_transports = {}
modules.register_modules(self)
......@@ -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
log.info('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
modules.unregister_modules(self)
def quit(self, kill_core):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment