Beispiel #1
0
 def run(self):
     from diesel.app import ApplicationEnd
     self.running = True
     self.app.running.add(self)
     parent_died = False
     try:
         self.loop_callable(*self.args, **self.kw)
     except TerminateLoop:
         pass
     except (SystemExit, KeyboardInterrupt, ApplicationEnd):
         raise
     except ParentDiedException:
         parent_died = True
     except:
         log.trace().error("-- Unhandled Exception in local loop <%s> --" % self.loop_label)
     finally:
         if self.connection_stack:
             assert len(self.connection_stack) == 1
             self.connection_stack.pop().close()
     self.deaths += 1
     self.running = False
     self.app.running.remove(self)
     # Keep-Alive Laws
     # ---------------
     # 1) Parent loop death always kills off children.
     # 2) Child loops with keep-alive resurrect if their parent didn't die.
     # 3) If a parent has died, a child always dies.
     self.notify_children()
     if self.keep_alive and not parent_died:
         log.warning("(Keep-Alive loop %s died; restarting)" % self)
         self.reset()
         self.hub.call_later(0.5, self.wake)
     elif self.parent and self in self.parent.children:
         self.parent.children.remove(self)
         self.parent = None
Beispiel #2
0
    def run(self):
        from diesel.app import ApplicationEnd
        self.running = True
        self.app.running.add(self)
        try:
            self.loop_callable(*self.args, **self.kw)
        except TerminateLoop:
            pass
        except (SystemExit, KeyboardInterrupt, ApplicationEnd):
            raise
        except ParentDiedException:
            pass
        except:
            log.trace().error("-- Unhandled Exception in local loop <%s> --" % self.loop_label)
        finally:
            if self.connection_stack:
                assert len(self.connection_stack) == 1
                self.connection_stack.pop().close()
        self.running = False
        self.app.running.remove(self)
        self.notify_children()
        if self.parent and self in self.parent.children:
            self.parent.children.remove(self)
            self.parent = None

        if self.keep_alive:
            log.warning("(Keep-Alive loop %s died; restarting)" % self)
            self.reset()
            self.hub.call_later(0.5, self.wake)
Beispiel #3
0
    def run(self):
        from diesel.app import ApplicationEnd
        self.running = True
        self.app.running.add(self)
        try:
            self.loop_callable(*self.args, **self.kw)
        except TerminateLoop:
            pass
        except (SystemExit, KeyboardInterrupt, ApplicationEnd):
            raise
        except ParentDiedException:
            pass
        except:
            log.trace().error("-- Unhandled Exception in local loop <%s> --" % self.loop_label)
        finally:
            if self.connection_stack:
                assert len(self.connection_stack) == 1
                self.connection_stack.pop().close()
        self.running = False
        self.app.running.remove(self)
        self.notify_children()
        if self.parent and self in self.parent.children:
            self.parent.children.remove(self)
            self.parent = None

        if self.keep_alive:
            log.warning("(Keep-Alive loop %s died; restarting)" % self)
            self.reset()
            self.hub.call_later(0.5, self.wake)
Beispiel #4
0
 def run(self):
     from diesel.app import ApplicationEnd
     self.running = True
     self.app.running.add(self)
     parent_died = False
     try:
         self.loop_callable(*self.args, **self.kw)
     except TerminateLoop:
         pass
     except (SystemExit, KeyboardInterrupt, ApplicationEnd):
         raise
     except ParentDiedException:
         parent_died = True
     except:
         log.trace().error("-- Unhandled Exception in local loop <%s> --" % self.loop_label)
     finally:
         if self.connection_stack:
             assert len(self.connection_stack) == 1
             self.connection_stack.pop().close()
     self.deaths += 1
     self.running = False
     self.app.running.remove(self)
     # Keep-Alive Laws
     # ---------------
     # 1) Parent loop death always kills off children.
     # 2) Child loops with keep-alive resurrect if their parent didn't die.
     # 3) If a parent has died, a child always dies.
     self.notify_children()
     if self.keep_alive and not parent_died:
         log.warning("(Keep-Alive loop %s died; restarting)" % self)
         self.reset()
         self.hub.call_later(0.5, self.wake)
     elif self.parent and self in self.parent.children:
         self.parent.children.remove(self)
         self.parent = None