def respawn_callback(self, deadproc): """Callback that performs a respawn, for persistent services.""" if deadproc.exitstatus.status == 127: deadproc.log( "*** process '%s' didn't start (NOT restarting).\n" % (deadproc.cmdline,)) raise ProcessError("Process never started. Check command line.") elif not deadproc.exitstatus: deadproc.log( "*** process '%s' died: %s (restarting in 1 sec.).\n" % ( deadproc.cmdline, deadproc.exitstatus)) scheduler.add(1.0, pri=0, callback=self._respawn, args=(deadproc,)) else: deadproc.log( "*** process '%s' normal exit (NOT restarting).\n" % (deadproc.cmdline,)) return None
def respawn_callback(self, deadproc): """Callback that performs a respawn, for persistent services.""" if deadproc.exitstatus.status == 127: deadproc.log("*** process '%s' didn't start (NOT restarting).\n" % (deadproc.cmdline, )) raise ProcessError("Process never started. Check command line.") elif not deadproc.exitstatus: deadproc.log( "*** process '%s' died: %s (restarting in 1 sec.).\n" % (deadproc.cmdline, deadproc.exitstatus)) scheduler.add(1.0, pri=0, callback=self._respawn, args=(deadproc, )) else: deadproc.log("*** process '%s' normal exit (NOT restarting).\n" % (deadproc.cmdline, )) return None
def Schedule(self, delay, cb): """Callback scheduler. Schedule a function to run 'delay' seconds in the future. """ return scheduler.add(delay, callback=cb)
def schedule(self, delay, cb): """Schedule a callback to run 'delay' seconds in the future.""" return scheduler.add(delay, callback=cb)