404

[ Avaa Bypassed ]




Upload:

Command:

elspacio@18.217.23.20: ~ $
from __future__ import unicode_literals

from timeit import default_timer

from .decorator import decorate


class ExceptionCounter(object):
    def __init__(self, counter, exception):
        self._counter = counter
        self._exception = exception

    def __enter__(self):
        pass

    def __exit__(self, typ, value, traceback):
        if isinstance(value, self._exception):
            self._counter.inc()

    def __call__(self, f):
        def wrapped(func, *args, **kwargs):
            with self:
                return func(*args, **kwargs)

        return decorate(f, wrapped)


class InprogressTracker(object):
    def __init__(self, gauge):
        self._gauge = gauge

    def __enter__(self):
        self._gauge.inc()

    def __exit__(self, typ, value, traceback):
        self._gauge.dec()

    def __call__(self, f):
        def wrapped(func, *args, **kwargs):
            with self:
                return func(*args, **kwargs)

        return decorate(f, wrapped)


class Timer(object):
    def __init__(self, callback):
        self._callback = callback

    def _new_timer(self):
        return self.__class__(self._callback)

    def __enter__(self):
        self._start = default_timer()

    def __exit__(self, typ, value, traceback):
        # Time can go backwards.
        duration = max(default_timer() - self._start, 0)
        self._callback(duration)

    def __call__(self, f):
        def wrapped(func, *args, **kwargs):
            # Obtaining new instance of timer every time
            # ensures thread safety and reentrancy.
            with self._new_timer():
                return func(*args, **kwargs)

        return decorate(f, wrapped)

Filemanager

Name Type Size Permission Actions
__pycache__ Folder 0755
bridge Folder 0755
openmetrics Folder 0755
twisted Folder 0755
__init__.py File 1.77 KB 0644
asgi.py File 1.16 KB 0644
context_managers.py File 1.65 KB 0644
core.py File 895 B 0644
decorator.py File 15.43 KB 0644
exposition.py File 14.92 KB 0644
gc_collector.py File 1.42 KB 0644
metrics.py File 21.66 KB 0644
metrics_core.py File 11.6 KB 0644
mmap_dict.py File 5.14 KB 0644
multiprocess.py File 6.32 KB 0644
parser.py File 7.09 KB 0644
platform_collector.py File 1.69 KB 0644
process_collector.py File 3.57 KB 0644
registry.py File 5.23 KB 0644
samples.py File 1.33 KB 0644
utils.py File 621 B 0644
values.py File 3.75 KB 0644