8000 Merge pull request #644 from prometheus/fix-mark_process_dead-old-env… · ethervoid/client_python@84f526b · GitHub
[go: up one dir, main page]

Skip to content

Commit 84f526b

Browse files
authored
Merge pull request prometheus#644 from prometheus/fix-mark_process_dead-old-env-var
mark_process_dead respects old env var
2 parents 7bbf86f + 9d745ed commit 84f526b

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

prometheus_client/multiprocess.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def collect(self):
157157
def mark_process_dead(pid, path=None):
158158
"""Do bookkeeping for when one process dies in a multi-process setup."""
159159
if path is None:
160-
path = os.environ.get('PROMETHEUS_MULTIPROC_DIR')
160+
path = os.environ.get('PROMETHEUS_MULTIPROC_DIR', os.environ.get('prometheus_multiproc_dir'))
161161
for f in glob.glob(os.path.join(path, 'gauge_livesum_{0}.db'.format(pid))):
162162
os.remove(f)
163163
for f in glob.glob(os.path.join(path, 'gauge_liveall_{0}.db'.format(pid))):

tests/test_multiprocess.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ def setUp(self):
3030
self.tempdir = tempfile.mkdtemp()
3131

3232
def tearDown(self):
33-
del os.environ['prometheus_multiproc_dir']
34-
del os.environ['PROMETHEUS_MULTIPROC_DIR']
33+
os.environ.pop('prometheus_multiproc_dir', None)
34+
os.environ.pop('PROMETHEUS_MULTIPROC_DIR', None)
3535
values.ValueClass = MutexValue
3636
shutil.rmtree(self.tempdir)
3737

@@ -48,6 +48,12 @@ def test_deprecation_warning(self):
4848
assert issubclass(w[-1].category, DeprecationWarning)
4949
assert "PROMETHEUS_MULTIPROC_DIR" in str(w[-1].message)
5050

51+
def test_mark_process_dead_respects_lowercase(self):
52+
os.environ['prometheus_multiproc_dir'] = self.tempdir
53+
# Just test that this does not raise with a lowercase env var. The
54+
# logic is tested elsewhere.
55+
mark_process_dead(123)
56+
5157

5258
class TestMultiProcess(unittest.TestCase):
5359
def setUp(self):

0 commit comments

Comments
 (0)
0