Esempio n. 1
0
 def _try_to_connect(self, furl_or_file, delay, max_tries, attempt):
     """Try to connect to the controller with retry logic."""
     if attempt < max_tries:
         log.msg("Attempting to connect to controller [%r]: %s" % \
             (attempt, furl_or_file))
         try:
             self.furl = find_furl(furl_or_file)
             # Uncomment this to see the FURL being tried.
             # log.msg("FURL: %s" % self.furl)
             rr = yield self.tub.getReference(self.furl)
         except:
             if attempt==max_tries-1:
                 # This will propagate the exception all the way to the top
                 # where it can be handled.
                 raise
             else:
                 yield sleep_deferred(delay)
                 rr = yield self._try_to_connect(
                     furl_or_file, 1.5*delay, max_tries, attempt+1
                 )
                 # rr becomes an int when there is a connection!!!
                 returnValue(rr)
         else:
             returnValue(rr)
     else:
         raise EngineConnectorError(
             'Could not connect to controller, max_tries (%r) exceeded. '
             'This usually means that i) the controller was not started, '
             'or ii) a firewall was blocking the engine from connecting '
             'to the controller.' % max_tries
         )
Esempio n. 2
0
 def interrupt_then_kill(self, delay=2.0):
     """Send INT, wait a delay and then send KILL."""
     yield self.signal('INT')
     yield sleep_deferred(delay)
     yield self.signal('KILL')
Esempio n. 3
0
 def interrupt_then_kill(self, delay=2.0):
     """Send INT, wait a delay and then send KILL."""
     yield self.signal('INT')
     yield sleep_deferred(delay)
     yield self.signal('KILL')