Ejemplo n.º 1
0
    def __repr__(self, _repr_running=None):
        # od.__repr__() <==> repr(od)
        call_key = id(self), _get_ident()
        _repr_running = _repr_running or dict()

        if call_key in _repr_running:
            return '...'

        _repr_running[call_key] = 1
        try:
            if not self:
                return ''

            # Convert to JSON but strip off outside '{}'
            msg = '"msg":"{}",'.format(self.pop('event', 'n/a'))
            json_msg = json.dumps(self,
                                  indent=None,
                                  cls=EncoderFix,
                                  separators=(', ', ': '),
                                  sort_keys=True)[1:-1]

            # Extract trace fields for log correlation
            log_correlation_fields = extract_context_attributes()

            if log_correlation_fields:
                json_msg += ',' + json.dumps(log_correlation_fields,
                                             indent=None,
                                             separators=(', ', ': '))[1:-1]
            return msg + json_msg

        finally:
            del _repr_running[call_key]
Ejemplo n.º 2
0
        def acquire(self):
            me = _get_ident()
            if self._owner == me:
                self._count += 1
                return

            self._owner = me
            self._block.acquire()
            self._count = 1
Ejemplo n.º 3
0
        def acquire(self):
            me = _get_ident()
            if self._owner == me:
                self._count += 1
                return

            self._owner = me
            self._block.acquire()
            self._count = 1
 def __repr__(self, _repr_running={}):
     call_key = id(self), _get_ident()
     if call_key in _repr_running:
         return '...'
     _repr_running[call_key] = 1
     try:
         return '%s(%s, %r)' % (self.__class__.__name__, self.default_factory, dict(list(self.items())))
     finally:
         del _repr_running[call_key]
Ejemplo n.º 5
0
 def __repr__(self, _repr_running={}):
     call_key = id(self), _get_ident()
     if call_key in _repr_running:
         return '...'
     _repr_running[call_key] = 1
     try:
         if not self:
             return '%s()' % (self.__class__.__name__, )
         return '%s(%r)' % (self.__class__.__name__, dict(self.items()))
     finally:
         del _repr_running[call_key]
 def __repr__(self, _repr_running={}):
     call_key = id(self), _get_ident()
     if call_key in _repr_running:
         return '...'
     _repr_running[call_key] = 1
     try:
         if not self:
             return '%s()' % (self.__class__.__name__,)
         return '%s(%r)' % (self.__class__.__name__, dict(list(self.items())))
     finally:
         del _repr_running[call_key]
Ejemplo n.º 7
0
 def __repr__(self, _repr_running={}):  # pylint: disable=W0102
     'od.__repr__() <==> repr(od)'
     call_key = id(self), _get_ident()
     if call_key in _repr_running:
         return '...'
     _repr_running[call_key] = 1
     try:
         if not self:
             return '{0}()'.format(self.__class__.__name__)
         return '{0}(\'{1}\')'.format(self.__class__.__name__, list(self.items()))
     finally:
         del _repr_running[call_key]
 def __repr__(self, _repr_running={}):
     "od.__repr__() <==> repr(od)"
     call_key = id(self), _get_ident()
     if call_key in _repr_running:
         return "..."
     _repr_running[call_key] = 1
     try:
         if not self:
             return "%s()" % (self.__class__.__name__, )
         return "%s(%r)" % (self.__class__.__name__, list(self.items()))
     finally:
         del _repr_running[call_key]
Ejemplo n.º 9
0
 def __repr__(self, _repr_running={}, prefix = '' ):
     call_key = id(self), _get_ident()
     if _repr_running is None:
         _repr_running = {}
     if call_key in _repr_running:
         return '...'
     _repr_running[call_key] = 1
     try:
         if self is None:
             return '%s()' % (self.__class__.__name__,)
         return '\n'.join(self._repr_gen(prefix))
     finally:
         del _repr_running[call_key]
Ejemplo n.º 10
0
 def __repr__(self, _repr_running={}):  # pylint: disable=W0102
     "od.__repr__() <==> repr(od)"
     call_key = id(self), _get_ident()
     if call_key in _repr_running:
         return "..."
     _repr_running[call_key] = 1
     try:
         if not self:
             return "{}()".format(self.__class__.__name__)
         return "{}('{}')".format(self.__class__.__name__,
                                  list(self.items()))
     finally:
         del _repr_running[call_key]
Ejemplo n.º 11
0
 def __repr__(self, _repr_running={}):
     'od.__repr__() <==> repr(od)'
     call_key = id(self), _get_ident()
     if call_key in _repr_running:
         return '...'
     _repr_running[call_key] = 1
     try:
         if not self:
             return "{0}()".format(self.__class__.__name__)
         return '{0}({1:r})'.format(
             self.__class__.__name__, self.items())
     finally:
         del _repr_running[call_key]
Ejemplo n.º 12
0
 def __repr__(self, _repr_running={}, prefix=""):
     call_key = id(self), _get_ident()
     if _repr_running is None:
         _repr_running = {}
     if call_key in _repr_running:
         return "..."
     _repr_running[call_key] = 1
     try:
         if self is None:
             return "%s()" % (self.__class__.__name__, )
         return "\n".join(self._repr_gen(prefix))
     finally:
         del _repr_running[call_key]
 def __repr__(self, _repr_running=None):
     'od.__repr__() <==> repr(od)'
     if not _repr_running: _repr_running = {}
     call_key = id(self), _get_ident()
     if call_key in _repr_running:
         return '...'
     _repr_running[call_key] = 1
     try:
         if not self:
             return '%s()' % (self.__class__.__name__, )
         return '%s(%r)' % (self.__class__.__name__, list(self.items()))
     finally:
         del _repr_running[call_key]
Ejemplo n.º 14
0
 def __repr__(self, _repr_running={}):
     '''x.__repr__() <==> repr(x)
     '''
     call_key = id(self), _get_ident()
     if call_key in _repr_running:
         return '...'
     _repr_running[call_key] = 1
     try:
         if not self:
             return '%s()' % (self.__class__.__name__,)
         return '%s(%r)' % (self.__class__.__name__, list(self.__values.values()))
     finally:
         del _repr_running[call_key]
Ejemplo n.º 15
0
 def __repr__(self, _repr_running={}):
     'od.__repr__() <==> repr(od)'
     call_key = id(self), _get_ident()
     if call_key in _repr_running:
         return '...'
     _repr_running[call_key] = 1
     try:
         if not self:
             return '{}'
         return '{%s}' % ", ".join("%s: %s" % (k, v)
                                   for k, v in self.items())
     finally:
         del _repr_running[call_key]
Ejemplo n.º 16
0
 def __repr__(self, _repr_running=None):
     """od.__repr__() <==> repr(od)"""
     if _repr_running is None:
         _repr_running = {}
     call_key = id(self), _get_ident()
     if call_key in _repr_running:
         return '...'
     _repr_running[call_key] = 1
     try:
         if not self:
             return '{0}()'.format(self.__class__.__name__)
         return '{0}({1:r})'.format(self.__class__.__name__,
                                    list(self.items()))
     finally:
         del _repr_running[call_key]
Ejemplo n.º 17
0
 def __repr__(self, _repr_running=None):
     """od.__repr__() <==> repr(od)"""
     if _repr_running is None:
         _repr_running = {}
     call_key = id(self), _get_ident()
     if call_key in _repr_running:
         return '...'
     _repr_running[call_key] = 1
     try:
         if not self:
             return '{0}()'.format(self.__class__.__name__)
         return '{0}({1:r})'.format(
             self.__class__.__name__, list(self.items()))
     finally:
         del _repr_running[call_key]
Ejemplo n.º 18
0
        def wrapper(self):
            me = _get_ident()
            try:
                count = self._locking[me]
            except KeyError:
                count = self._locking[me] = 1
            else:
                count = self._locking[me] = count + 1
            if count:
                return

            try:
                return f(self)
            finally:
                count = count - 1
                if not count:
                    del self._locking[me]
                else:
                    self._locking[me] = count
Ejemplo n.º 19
0
        def wrapper(self):
            me = _get_ident()
            try:
                count = self._locking[me]
            except KeyError:
                count = self._locking[me] = 1
            else:
                count = self._locking[me] = count + 1
            if count:
                return

            try:
                return f(self)
            finally:
                count = count - 1
                if not count:
                    del self._locking[me]
                else:
                    self._locking[me] = count
Ejemplo n.º 20
0
    def __repr__(self, _repr_running=None):
        # od.__repr__() <==> repr(od)
        call_key = id(self), _get_ident()
        _repr_running = _repr_running or dict()

        if call_key in _repr_running:
            return '...'

        _repr_running[call_key] = 1
        try:
            if not self:
                return ''

            # Convert to JSON but strip off outside '{}'
            msg = '"msg":"{}",'.format(self.pop('event'))
            json_msg = json.dumps(self, indent=None,
                                  cls=EncoderFix,
                                  separators=(', ', ': '),
                                  sort_keys=True)[1:-1]
            return msg + json_msg

        finally:
            del _repr_running[call_key]