8000 multiprocess: pass None as default argument (#212) · umax/client_python@3679aa2 · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3679aa2

Browse files
dzenbrian-brazil
authored andcommitted
multiprocess: pass None as default argument (prometheus#212)
The goal here is to evaluate the environ only at parse time to allow to mock environment variables
1 parent d4a2ecf commit 3679aa2

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

prometheus_client/multiprocess.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111

1212
class MultiProcessCollector(object):
1313
"""Collector for files for multi-process mode."""
14-
def __init__(self, registry, path=os.environ.get('prometheus_multiproc_dir')):
14+
def __init__(self, registry, path=None):
15+
if path is None:
16+
path = os.environ.get('prometheus_multiproc_dir')
1517
if not path or not os.path.isdir(path):
1618
raise ValueError('env prometheus_multiproc_dir is not set or not a directory')
1719
self._path = path
@@ -88,8 +90,10 @@ def collect(self):
8890
return metrics.values()
8991

9092

91-
def mark_process_dead(pid, path=os.environ.get('prometheus_multiproc_dir')):
93+
def mark_process_dead(pid, path=None):
9294
"""Do bookkeeping for when one process dies in a multi-process setup."""
95+
if path is None:
96+
path = os.environ.get('prometheus_multiproc_dir')
9397
for f in glob.glob(os.path.join(path, 'gauge_livesum_{0}.db'.format(pid))):
9498
os.remove(f)
9599
for f in glob.glob(os.path.join(path, 'gauge_liveall_{0}.db'.format(pid))):

0 commit comments

Comments
 (0)
0