diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 731b47b..e31b2f7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -5,7 +5,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.7.15", "3.8.12", "3.9.12"] + python-version: ["3.9", "3.10"] steps: - uses: actions/checkout@v3 # memcached diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a7ce77..1380853 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ --- +## [1.2.2] - 2025-01-14 + +changed: + +- handle exceptions on prometheus operations + ## [1.2.1] - 2024-04-29 ### Added: diff --git a/cachext/__init__.py b/cachext/__init__.py index 3f262a6..923b987 100644 --- a/cachext/__init__.py +++ b/cachext/__init__.py @@ -1 +1 @@ -__version__ = '1.2.1' +__version__ = '1.2.2' diff --git a/cachext/cache.py b/cachext/cache.py index c358286..35663bc 100644 --- a/cachext/cache.py +++ b/cachext/cache.py @@ -67,8 +67,10 @@ def wrapper(*args, **kwargs): self.monitor_label_builder(f, *args, **kwargs) ) if self.request_counter: - # Increment request counter. - self.request_counter.labels(*labels).inc() + try: + self.request_counter.labels(*labels).inc() + except Exception as e: + print("request_counter.labels(*labels).inc() error: ", e) if rv is None: rv = f(*args, **kwargs) if self.cache_none and rv is None: @@ -78,8 +80,10 @@ def wrapper(*args, **kwargs): if callable(self.fallbacked): self.fallbacked(wrapper, rv, *args, **kwargs) elif self.hit_counter: - # Increment hit counter. - self.hit_counter.labels(*labels).inc() + try: + self.hit_counter.labels(*labels).inc() + except Exception as e: + print("hit_counter.labels(*labels).inc() error: ", e) if self.cache_none and rv is CacheNone: return None return rv