8000 Merge branch 'prometheus:master' into master · HelloBroBro/client_python@f115443 · GitHub
[go: up one dir, main page]

Skip to content

Commit f115443

Browse files
authored
Merge branch 'prometheus:master' into master
2 parents 09c5226 + ef95c4b commit f115443

File tree

7 files changed

+17
-27
lines changed

7 files changed

+17
-27
lines changed

.circleci/config.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ workflows:
7575
matrix:
7676
parameters:
7777
python:
78-
- "3.8.18"
7978
- "3.9.18"
8079
- "3.10"
8180
- "3.11"
< 8000 /code>
@@ -89,4 +88,4 @@ workflows:
8988
matrix:
9089
parameters:
9190
python:
92-
- "3.8"
91+
- "3.9"

prometheus_client/metrics.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import os
2-
from threading import RLock
2+
from threading import Lock
33
import time
44
import types
55
from typing import (
@@ -120,7 +120,7 @@ def __init__(self: T,
120120

121121
if self._is_parent():
122122
# Prepare the fields needed for child metrics.
123-
self._lock = RLock()
123+
self._lock = Lock()
124124
self._metrics: Dict[Sequence[str], T] = {}
125125

126126
if self._is_observable():
@@ -673,7 +673,7 @@ class Info(MetricWrapperBase):
673673

674674
def _metric_init(self):
675675
self._labelname_set = set(self._labelnames)
676-
self._lock = RLock()
676+
self._lock = Lock()
677677
self._value = {}
678678

679679
def info(self, val: Dict[str, str]) -> None:
@@ -735,7 +735,7 @@ def __init__(self,
735735

736736
def _metric_init(self) -> None:
737737
self._value = 0
738-
self._lock = RLock()
738+
self._lock = Lock()
739739

740740
def state(self, state: str) -> None:
741741
"""Set enum metric state."""

prometheus_client/registry.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from abc import ABC, abstractmethod
22
import copy
3-
from threading import RLock
3+
from threading import Lock
44
from typing import Dict, Iterable, List, Optional
55

66
from .metrics_core import Metric
@@ -30,7 +30,7 @@ def __init__(self, auto_describe: bool = False, target_info: Optional[Dict[str,
3030
self._collector_to_names: Dict[Collector, List[str]] = {}
3131
self._names_to_collectors: Dict[str, Collector] = {}
3232
self._auto_describe = auto_describe
33-
self._lock = RLock()
33+
self._lock = Lock()
3434
self._target_info: Optional[Dict[str, str]] = {}
3535
self.set_target_info(target_info)
3636

prometheus_client/values.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import os
2-
from threading import RLock
2+
from threading import Lock
33
import warnings
44

55
from .mmap_dict import mmap_key, MmapedDict
@@ -13,7 +13,7 @@ class MutexValue:
1313
def __init__(self, typ, metric_name, name, labelnames, labelvalues, help_text, **kwargs):
1414
self._value = 0.0
1515
self._exemplar = None
16-
self._lock = RLock()
16+
self._lock = Lock()
1717

1818
def inc(self, amount):
1919
with self._lock:
@@ -50,7 +50,7 @@ def MultiProcessValue(process_identifier=os.getpid):
5050
# Use a single global lock when in multi-processing mode
5151
# as we presume this means there is no threading going on.
5252
# This avoids the need to also have mutexes in __MmapDict.
53-
lock = RLock()
53+
lock = Lock()
5454

5555
class MmapedValue:
5656
"""A float protected by a mutex backed by a per-process mmaped file."""

setup.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,14 @@
3030
'twisted': ['twisted'],
3131
},
3232
test_suite="tests",
33-
python_requires=">=3.8",
33+
python_requires=">=3.9",
3434
classifiers=[
3535
"Development Status :: 4 - Beta",
36< 9E88 /td>36
"Intended Audience :: Developers",
3737
"Intended Audience :: Information Technology",
3838
"Intended Audience :: System Administrators",
3939
"Programming Language :: Python",
4040
"Programming Language :: Python :: 3",
41-
"Programming Language :: Python :: 3.8",
4241
"Programming Language :: Python :: 3.9",
4342
"Programming Language :: Python :: 3.10",
4443
"Programming Language :: Python :: 3.11",

tests/test_core.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,6 @@
1919
)
2020

2121

22-
def is_locked(lock):
23-
"Tries to obtain a lock, returns True on success, False on failure."
24-
locked = lock.acquire(blocking=False)
25-
if locked:
26-
lock.release()
27-
return not locked
28-
29-
3022
def assert_not_observable(fn, *args, **kwargs):
3123
"""
3224
Assert that a function call falls with a ValueError exception containing
@@ -1012,7 +1004,7 @@ def test_restricted_registry_does_not_yield_while_locked(self):
10121004
m = Metric('target', 'Target metadata', 'info')
10131005
m.samples = [Sample('target_info', {'foo': 'bar'}, 1)]
10141006
for _ in registry.restricted_registry(['target_info', 's_sum']).collect():
1015-
self.assertFalse(is_locked(registry._lock))
1007+
self.assertFalse(registry._lock.locked())
10161008

10171009

10181010
if __name__ == '__main__':

tox.ini

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
[tox]
2-
envlist = coverage-clean,py{3.8,3.9,3.10,3.11,3.12,py3.8,3.9-nooptionals},coverage-report,flake8,isort,mypy
2+
envlist = coverage-clean,py{3.9,3.10,3.11,3.12,py3.9,3.9-nooptionals},coverage-report,flake8,isort,mypy
33

44
[testenv]
55
deps =
66
coverage
77
pytest
88
attrs
9-
{py3.8,pypy3.8}: twisted
10-
py3.8: asgiref
11-
# See https://github.com/django/asgiref/issues/393 for why we need to pin asgiref for pypy
12-
pypy3.8: asgiref==3.6.0
9+
{py3.9,pypy3.9}: twisted
10+
# NOTE: Pinned due to https://github.com/prometheus/client_python/issues/1020
11+
py3.9: asgiref==3.7
12+
pypy3.9: asgiref==3.7
1313
commands = coverage run --parallel -m pytest {posargs}
1414

1515
[testenv:py3.9-nooptionals]

0 commit comments

Comments
 (0)
0