Example #1
0
def _clr_trace_local():
    if  coro.get_local(CORO_LOCAL_TCTRL, {}).get('clear', False):
        data = coro.pop_local(CORO_LOCAL_TCTRL, {})
    else:
        data = coro.get_local(CORO_LOCAL_TCTRL, {})

    return data.get('value', False)
Example #2
0
    def execute(self, vid, call, seq, server, **kwargs):
        cmd      = call.get('command', None)
        args     = call.get('args', ())
        kwargs   = call.get('kwargs', {})
        tlb, tval = call.get('tlb', ('tlb-%s' % self._objname, False))
        slv, sval = call.get('slave', ('slave-read', False))
        source    = call.get('source')

        self.debug(
            'execute command %r id %r args %r kwargs %r tlb %s slv %s',
            cmd, vid, args, kwargs, (tlb,tval), (slv,sval))

        try:
            coro.set_local(tlb, tval)
            coro.set_local(slv, sval)
            if source: coro.set_local(access.CORO_LOCAL_SOURCE, source)
            try:
                result = self._execute(vid, cmd, args, kwargs)
            finally:
                coro.pop_local(slv)
                coro.pop_local(tlb)
                coro.pop_local(access.CORO_LOCAL_SOURCE)
        except error.AccessError, e:
            self.warn('AccessError: %r %r' % (e, e.args,))

            result = {
                'rc':   e.id,
                'msg':  e[0],
                'args': e.args,
                'envl': True}

            self.clear()
Example #3
0
def trace_dump(clear = True):
    '''trace_dump

    Dump to stdout current trace data at the current trace level. An optional
    clear parameter to reset or preserve the trace data. (default: True)

    See Also: enable_trace()
    '''
    if clear:
        tdata = coro.pop_local(CORO_LOCAL_TDATA, {})
        tlevl = _clr_trace_local()
    else:
        tdata = coro.get_local(CORO_LOCAL_TDATA, {})
        tlevl = _get_trace_local()

    if not tlevl:
        return None

    total, idcnt, count = 0, 0, 0
    
    for obj, data in tdata.items():
        for cmd, (elapse, ids, cnt) in data.items():
            total += elapse
            count += cnt
            idcnt += ids

            if tlevl > ACCESS_TRACE_TERSE:
                print 'Access | %0.4f | %4d | %4d | Summary (%s.%s)' % (
                    elapse, cnt, ids, obj, cmd)

    if not total:
        return None

    lmt = has_trace_limits()
    if lmt is None:
        lmt = ''
    else:
        lmt = 'limit: %s' % lmt
    print 'Access | %.4f | %4d | %4d | Summary (TOTAL) %s' % (
        total, count, idcnt, lmt)