1. Marcin Kasperski
  2. mekk.fics

Commits

Marcin Kasperski  committed a670ad0

small fixes

  • Participants
  • Parent commits 632bf4a
  • Branches default

Comments (0)

Files changed (1)

File src/mekk/fics/fics_connector.py

View file
 from mekk.fics.parsing.fics_parser import FicsTextProcessor
 from mekk.fics.support.list_cache import ListCache
 from mekk.fics.command_building import ivar_login
+from mekk.fics.twisted_util import defer_util
 
 logger_net = logging.getLogger('fics.net')
 logger_lib = logging.getLogger('fics.lib')
         operations are finished.
         """
         try:
+            logger_lib.debug("%s: logged in as %s" % (self.label, self._fics_handle))
+
+            # Gathering replies so requests can proceed in parallel
             pending_defs = []
+
             vs = self.variables_to_set_after_login
             for var, value in vs.iteritems():
                 pending_defs.append(
             # TODO: virtualize somehow channel subscriptions
             pending_defs.append(
                 self.run_command("- channel 53"))
-            logger_lib.debug("%s: logged in as %s" % (self.label, self._fics_handle))
             if self.client.use_keep_alive:
                 self._keep_alive = KeepAliveExecutor(
                     label=self.label,
                     check_frequency_in_seconds=self.client.command_execution_timeout / 3,
                     timeout_in_seconds=self.client.command_execution_timeout,
                     on_timeouts=self.on_command_timeout)
-            # TODO: this is wrong as single exception leaves remaining defs uncaught
-            yield defer.gatherResults([d for d in pending_defs if d])
-            r = self.client.on_login(self._fics_handle)
-            yield r
+
+            # Await for configuration finish
+            yield defer_util.gather_with_cancel([
+                d for d in pending_defs if d])
+
+            # Custom initialization
+            yield self.client.on_login(self._fics_handle)
+
         except twisted_error.ConnectionDone as e:
             logger_lib.info("%s: Cleanly disconnected while handling on_login (%s). This is normal in one-shot clients." % (
                 self.label, str(e)))