def run(self): '''Start up an Application--blocks until the program ends or .halt() is called. ''' self._run = True log.warn('Starting diesel <%s>' % self.hub.describe) for s in self._services: s.bind_and_listen() s.register(self) for l in self._loops: self.hub.schedule(l.wake) self.setup() def main(): while self._run: try: self.hub.handle_events() except SystemExit: log.warn("-- SystemExit raised.. exiting main loop --") break except KeyboardInterrupt: log.warn("-- KeyboardInterrupt raised.. exiting main loop --") break except ApplicationEnd: log.warn("-- ApplicationEnd raised.. exiting main loop --") break except Exception, e: log.error("-- Unhandled Exception rose to main loop --") log.error(traceback.format_exc()) log.info('Ending diesel application') runtime.current_app = None
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.error("-- Unhandled Exception in local loop <%s> --" % self.loop_label) log.error(traceback.format_exc()) 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.warn("(Keep-Alive loop %s died; restarting)" % self) self.reset() self.hub.call_later(0.5, self.wake)
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: log.error("-- Unhandled Exception in local loop <%s> --" % self.loop_label) log.error(traceback.format_exc()) 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.warn("(Keep-Alive loop %s died; restarting)" % self) self.reset() self.hub.call_later(0.5, self.wake)
def hi_server(addr): while 1: ev, val = first(until_eol=True, sleep=3) if ev == 'sleep': log.warn('%s timeout!' % time.asctime()) else: send("you said %s" % val)
def run(self): """Start up an Application--blocks until the program ends or .halt() is called. """ self._run = True logmod.set_current_application(self) log.info("Starting diesel application") for s in self._services: s.bind_and_listen() self.hub.register(s.sock, s.accept_new_connection, None) for l in self._loops: l.iterate() self.setup() while self._run: try: self.hub.handle_events() except SystemExit: log.warn("-- SystemExit raised.. exiting main loop --") break except KeyboardInterrupt: log.warn("-- KeyboardInterrupt raised.. exiting main loop --") break except Exception, e: log.error("-- Unhandled Exception in main loop --") log.error(traceback.format_exc())
def run(self): from diesel.app import ApplicationEnd try: self.loop_callable(*self.args, **self.kw) except (SystemExit, KeyboardInterrupt, ApplicationEnd): raise except: log.error("-- Unhandled Exception in local loop --") log.error(traceback.format_exc()) finally: if self.connection_stack: assert len(self.connection_stack) == 1 self.connection_stack.pop().close() if self.keep_alive: log.warn("(Keep-Alive loop %s died; restarting)" % self) self.reset() self.hub.call_later(0.5, self.wake)
def run(self): '''Start up an Application--blocks until the program ends or .halt() is called. ''' self._run = True log.warn('Starting diesel <%s>' % self.hub.describe) for s in self._services: s.bind_and_listen() s.register(self) for l in self._loops: self.hub.schedule(l.wake) self.setup() def main(): while self._run: try: self.hub.handle_events() except SystemExit: log.warn("-- SystemExit raised.. exiting main loop --") break except KeyboardInterrupt: log.warn( "-- KeyboardInterrupt raised.. exiting main loop --") break except ApplicationEnd: log.warn("-- ApplicationEnd raised.. exiting main loop --") break except Exception, e: log.error("-- Unhandled Exception rose to main loop --") log.error(traceback.format_exc()) log.info('Ending diesel application') runtime.current_app = None
def main(): while self._run: try: self.hub.handle_events() except SystemExit: log.warn("-- SystemExit raised.. exiting main loop --") break except KeyboardInterrupt: log.warn("-- KeyboardInterrupt raised.. exiting main loop --") break except ApplicationEnd: log.warn("-- ApplicationEnd raised.. exiting main loop --") break except Exception, e: log.error("-- Unhandled Exception rose to main loop --") log.error(traceback.format_exc())
def main(): while self._run: try: self.hub.handle_events() except SystemExit: log.warn("-- SystemExit raised.. exiting main loop --") break except KeyboardInterrupt: log.warn( "-- KeyboardInterrupt raised.. exiting main loop --") break except ApplicationEnd: log.warn("-- ApplicationEnd raised.. exiting main loop --") break except Exception, e: log.error("-- Unhandled Exception rose to main loop --") log.error(traceback.format_exc())