GRAYBYTE WORDPRESS FILE MANAGER8441

Server IP : 198.54.121.189 / Your IP : 216.73.216.140
System : Linux premium69.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
PHP Version : 7.4.33
Disable Function : NONE
cURL : ON | WGET : ON | Sudo : OFF | Pkexec : OFF
Directory : /opt/hc_python/lib/python3.12/site-packages/prometheus_client/
Upload Files :
Current_dir [ Not Writeable ] Document_root [ Writeable ]

Command :


Current File : /opt/hc_python/lib/python3.12/site-packages/prometheus_client//context_managers.py
from timeit import default_timer
from types import TracebackType
from typing import (
    Any, Callable, Literal, Optional, Tuple, Type, TYPE_CHECKING, TypeVar,
    Union,
)

from .decorator import decorate

if TYPE_CHECKING:
    from . import Counter
    F = TypeVar("F", bound=Callable[..., Any])


class ExceptionCounter:
    def __init__(self, counter: "Counter", exception: Union[Type[BaseException], Tuple[Type[BaseException], ...]]) -> None:
        self._counter = counter
        self._exception = exception

    def __enter__(self) -> None:
        pass

    def __exit__(self, typ: Optional[Type[BaseException]], value: Optional[BaseException], traceback: Optional[TracebackType]) -> Literal[False]:
        if isinstance(value, self._exception):
            self._counter.inc()
        return False

    def __call__(self, f: "F") -> "F":
        def wrapped(func, *args, **kwargs):
            with self:
                return func(*args, **kwargs)

        return decorate(f, wrapped)


class InprogressTracker:
    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: "F") -> "F":
        def wrapped(func, *args, **kwargs):
            with self:
                return func(*args, **kwargs)

        return decorate(f, wrapped)


class Timer:
    def __init__(self, metric, callback_name):
        self._metric = metric
        self._callback_name = callback_name

    def _new_timer(self):
        return self.__class__(self._metric, self._callback_name)

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

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

    def labels(self, *args, **kw):
        self._metric = self._metric.labels(*args, **kw)

    def __call__(self, f: "F") -> "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)

[ Back ]
Name
Size
Last Modified
Owner / Group
Permissions
Options
..
--
May 23 2025 08:31:29
root / root
0755
__pycache__
--
April 04 2025 08:00:21
root / root
0755
bridge
--
April 04 2025 08:00:21
root / root
0755
openmetrics
--
April 04 2025 08:00:21
root / root
0755
twisted
--
April 04 2025 08:00:21
root / root
0755
__init__.py
1.772 KB
April 04 2025 08:00:21
root / root
0644
asgi.py
1.568 KB
April 04 2025 08:00:21
root / root
0644
context_managers.py
2.288 KB
April 04 2025 08:00:21
root / root
0644
core.py
0.84 KB
April 04 2025 08:00:21
root / root
0644
decorator.py
15.432 KB
April 04 2025 08:00:21
root / root
0644
exposition.py
25.563 KB
April 04 2025 08:00:21
root / root
0644
gc_collector.py
1.479 KB
April 04 2025 08:00:21
root / root
0644
metrics.py
27.45 KB
April 04 2025 08:00:21
root / root
0644
metrics_core.py
15.184 KB
April 04 2025 08:00:21
root / root
0644
mmap_dict.py
5.267 KB
April 04 2025 08:00:21
root / root
0644
multiprocess.py
7.362 KB
April 04 2025 08:00:21
root / root
0644
parser.py
7.26 KB
April 04 2025 08:00:21
root / root
0644
platform_collector.py
1.835 KB
April 04 2025 08:00:21
root / root
0644
process_collector.py
3.773 KB
April 04 2025 08:00:21
root / root
0644
py.typed
0 KB
April 04 2025 08:00:21
root / root
0644
registry.py
6.051 KB
April 04 2025 08:00:21
root / root
0644
samples.py
1.647 KB
April 04 2025 08:00:21
root / root
0644
utils.py
0.58 KB
April 04 2025 08:00:21
root / root
0644
values.py
4.885 KB
April 04 2025 08:00:21
root / root
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2025
CONTACT ME
Static GIF