code: def _execute_xmpp(connected_callback):
      
      from indico_chat.plugin import ChatPlugin
  
      check_config()
      jid = ChatPlugin.settings.get('bot_jid')
      password = ChatPlugin.settings.get('bot_password')
      if '@' not in jid:
          jid = '{}@{}'.format(jid, ChatPlugin.settings.get('server'))
  
      result = [None, None]  # result, exception
      app = current_app._get_current_object()  # callback runs in another thread
  
      def _session_start(event):
          try:
              with app.app_context():
                  result[0] = connected_callback(xmpp)
          except Exception as e:
              result[1] = e
              if isinstance(e, IqError):
                  current_plugin.logger.exception('XMPP callback failed: %s', e.condition)
              else:
                  current_plugin.logger.exception('XMPP callback failed')
          finally:
              xmpp.disconnect(wait=0)
  
      xmpp = ClientXMPP(jid, password)
      xmpp.register_plugin('xep_0045')
      xmpp.register_plugin('xep_0004')
      xmpp.register_plugin('xep_0030')
      xmpp.add_event_handler('session_start', _session_start)
  
      try:
          xmpp.connect()
      except Exception:
          current_plugin.logger.exception('XMPP connection failed')
          xmpp.disconnect()
          raise
  
      try:
          xmpp.process(threaded=False)
      finally:
          xmpp.disconnect(wait=0)
  
      if result[1] is not None:
          raise result[1]
  
      return result[0]
docs: Connects to the XMPP server and executes custom code
  
      :param connected_callback: function to execute after connecting
      :return: return value of the callback