コード例 #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)
コード例 #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))
コード例 #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
コード例 #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
コード例 #5
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
コード例 #6
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)
コード例 #7
0
 def handle_close (self):
     getlog().warning("Unhandled reactable close event")
コード例 #8
0
 def handle_write (self, data):
     getlog().warning("Unhandled reactable write event")
コード例 #9
0
 def handle_read (self):
     getlog().warning("Unhandled reactable read event")