def _run_until_current(self): self._insert_new_calledlaters() now = time.time() while self._pending_timed_calls and (self._pending_timed_calls[0].time <= now): call = heapq.heappop(self._pending_timed_calls) if call.cancelled: self._cancellations -= 1 continue if call.delayed_time > 0: call.activate_delay() heapq.heappush(self._pending_timed_calls, call) continue try: call.called = 1 call.func(*call.args, **call.kw) except _reraised_exceptions: raise except: getlog().exception("CallLater failed") if (self._cancellations > 50 and self._cancellations > len(self._pending_timed_calls) >> 1): self._cancellations = 0 self._pending_timed_calls = [ x for x in self._pending_timed_calls if not x.cancelled ] heapq.heapify(self._pending_timed_calls)
def _run_until_current (self): self._insert_new_calledlaters() now = time.time() while self._pending_timed_calls and (self._pending_timed_calls[0].time <= now): call = heapq.heappop(self._pending_timed_calls) if call.cancelled: self._cancellations -= 1 continue if call.delayed_time > 0: call.activate_delay() heapq.heappush(self._pending_timed_calls, call) continue try: call.called = 1 call.func(*call.args, **call.kw) except _reraised_exceptions: raise except: getlog().exception("CallLater failed") if (self._cancellations > 50 and self._cancellations > len(self._pending_timed_calls) >> 1): self._cancellations = 0 self._pending_timed_calls = [ x for x in self._pending_timed_calls if not x.cancelled ] heapq.heapify(self._pending_timed_calls)
def handle_error(self): try: self_repr = repr(self) except: self_repr = '<__repr__(self) failed for object at %0x>' % id(self) t, v, tb = sys.exc_info() while tb.tb_next: tb = tb.tb_next tbinfo = '[%s|%s|%s]' % (tb.tb_frame.f_code.co_filename, tb.tb_frame.f_code.co_name, str(tb.tb_lineno)) getlog().warning("Unhandled python exception: %s (%s:%s %s)" % (self_repr, t, v, tbinfo))
def handle_error (self): try: self_repr = repr(self) except: self_repr = '<__repr__(self) failed for object at %0x>' % id(self) t, v, tb = sys.exc_info() while tb.tb_next: tb = tb.tb_next tbinfo = '[%s|%s|%s]' % (tb.tb_frame.f_code.co_filename, tb.tb_frame.f_code.co_name, str(tb.tb_lineno)) getlog().warning("Unhandled python exception: %s (%s:%s %s)" % (self_repr, t, v, tbinfo))
def _waitpid(): # need pthread_sigmask here to avoid concurrent sigchld, but Python # does not offer it as its not standard across UNIX versions. There is # still a raise condition here; we can get a sigchld while we're # sitting in the waitpid call try: pid, sts = os.waitpid(-1, os.WNOHANG) except OSError, why: err = why[0] if errno in (errno.ECHILD, errno.EINTR): getlog().critical( "waitpid error; a process may not be cleaned up properly") if err == errno.EINTR: getlog().debug("EINTR during reap") pid, sts = None, None
def __init__(self, **kw): super(ParentController, self).__init__(**kw) self._parse_options(ParentController.options, kw) self.log = getlog() self.children = [] self.stopping = False self.stopping_children = None
def _except_hook(exc_type, value, tb): global _app_name, _app_version try: log = getlog() log.critical('Exception: please include the following information ' 'in any bug report:') log.critical(' %s version %s' % (_app_name, _app_version)) log.critical(' Python version %s' % sys.version.split('\n', 1)[0]) log.critical('') log.critical('Unhandled exception follows:') tblist = (traceback.format_tb(tb, None) + traceback.format_exception_only(exc_type, value)) if type(tblist) != list: tblist = [ tblist, ] for line in tblist: for l in line.split('\n'): if not l: continue log.critical('%s' % l.rstrip()) log.critical('') log.critical('Please also include configuration information from ' 'running %s' % _app_name) log.critical('with your normal options plus \'--dump\'') except: traceback.print_exception(exc_type, value, tb)
def __init__ (self, reporter_config, metrics_recorder, **kw): super(BaseReporter, self).__init__(**kw) #self._parse_options(BaseReporter.options, kw) self.reporter_config = reporter_config self.metrics_recorder = metrics_recorder self.log = getlog() self.setup()
def __init__ (self, prefix="", save_file=None): self.log = getlog() self.prefix = prefix self.save_file = save_file self.saved_metrics = None self.all_metrics = {} self.selfstats = None self.load_saved_metrics()
def setup (self): super(SquibMain, self).setup() self.log = getlog() self.rename_process() self.configure_metrics_recorder() self.configure_reporter() self.configure_oxidizers() self.configure_extra_oxidizers() self.configure_selfstats() self.daemonize() self.write_pid()
def __init__(self, name): self.name = name self.state = ChildStates.STOPPED self.pipes = {} self.reactables = [] self.log = getlog() self.priority = 999 self.startsecs = 12 self.startretries = 3 self.stopsignal = _signum("TERM") self.stopwaitsecs = 22
def _except_hook (exc_type, value, tb): global _app_name, _app_version try: log = getlog() log.critical('Exception: please include the following information ' 'in any bug report:') log.critical(' %s version %s' % (_app_name, _app_version)) log.critical(' Python version %s' % sys.version.split('\n',1)[0]) log.critical('') log.critical('Unhandled exception follows:') tblist = (traceback.format_tb(tb, None) + traceback.format_exception_only(exc_type, value)) if type(tblist) != list: tblist = [tblist, ] for line in tblist: for l in line.split('\n'): if not l: continue log.critical('%s' % l.rstrip()) log.critical('') log.critical('Please also include configuration information from ' 'running %s' % _app_name) log.critical('with your normal options plus \'--dump\'') except: traceback.print_exception(exc_type, value, tb)
def handle_write(self, data): getlog().warning("Unhandled reactable write event")
def __init__ (self, metrics_recorder, **kw): super(MetricsReader, self).__init__(**kw) self.metrics_recorder = metrics_recorder self.buff = '' self.log = getlog()
def __init__ (self, **kw): ReadOnlyFileDescriptorReactable.__init__(self, **kw) self.log = getlog()
def handle_close (self): getlog().warning("Unhandled reactable close event")
def handle_write (self, data): getlog().warning("Unhandled reactable write event")
def handle_read (self): getlog().warning("Unhandled reactable read event")
def __init__ (self, name, *args): self.name = name self.parse_args(args) self.log = getlog()
def handle_close(self): getlog().warning("Unhandled reactable close event")
def handle_read(self): getlog().warning("Unhandled reactable read event")