Beispiel #1
0
    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)
Beispiel #2
0
 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))
Beispiel #3
0
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
Beispiel #4
0
 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
Beispiel #5
0
 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()
Beispiel #6
0
 def setup (self):
     super(SquibMain, self).setup()
     self.log = getlog()
     self.configure_metrics_recorder()
     self.configure_reporter()
     self.configure_oxidizers()
     self.configure_selfstats()
     self.daemonize()
     self.write_pid()
Beispiel #7
0
    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
Beispiel #8
0
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)
Beispiel #9
0
 def handle_close(self):
     getlog().warning("Unhandled reactable close event")
Beispiel #10
0
 def handle_write(self, data):
     getlog().warning("Unhandled reactable write event")
Beispiel #11
0
 def handle_read(self):
     getlog().warning("Unhandled reactable read event")
Beispiel #12
0
 def __init__ (self, prefix=""):
     self.log = getlog()
     self.prefix = prefix
     self.all_metrics = {}
     self.selfstats = None
Beispiel #13
0
 def __init__ (self, name, *args):
     self.name = name
     self.parse_args(args)
     self.log = getlog()