def run(self): app = App.get_app(self._app_name) time_string = datetime.datetime.strftime(app.last_build_time, LogSettings.TIME_FORMAT) self._stream = AppLogStreamer(self._app_name, time_string).get_stream() while not self._stopped: time.sleep(0.05) try: msg = self._stream.next() if msg: self._ioloop.add_callback(self._handler.write_message, msg) except StopIteration: self.stop()
class LogsThread(Thread): def __init__(self, app_name, handler): super(LiveLogsHandler.LogsThread, self).__init__() self._app_name = app_name self._stream = None self._handler = handler self._stopped = False def stop(self): self._stopped = True def run(self): app = App.get_app(self._app_name) time_string = datetime.datetime.strftime(app.last_build_time, LogSettings.TIME_FORMAT) self._stream = AppLogStreamer(self._app_name, time_string).get_stream() while not self._stopped: # time.sleep(0.10) try: msg = self._stream.next() if msg: IOLoop.instance().add_callback(self._handler.write_message, msg) except StopIteration: self.stop() ws_handlers.remove(self._handler)
class LogsThread(Thread): def __init__(self, app_name, handler): super(LiveLogsHandler.LogsThread, self).__init__() self._app_name = app_name self._stream = None self._handler = handler self._stopped = False self._ioloop = IOLoop.instance() def stop(self): self._stopped = True def run(self): app = App.get_app(self._app_name) time_string = datetime.datetime.strftime(app.last_build_time, LogSettings.TIME_FORMAT) self._stream = AppLogStreamer(self._app_name, time_string).get_stream() while not self._stopped: time.sleep(0.05) try: msg = self._stream.next() if msg: self._ioloop.add_callback(self._handler.write_message, msg) except StopIteration: self.stop()