Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions prometheus_client/multiprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ def mark_process_dead(pid, path=None):
"""Do bookkeeping for when one process dies in a multi-process setup."""
if path is None:
path = os.environ.get('PROMETHEUS_MULTIPROC_DIR', os.environ.get('prometheus_multiproc_dir'))
if not path:
return
for mode in _LIVE_GAUGE_MULTIPROCESS_MODES:
for f in glob.glob(os.path.join(path, f'gauge_{mode}_{pid}.db')):
os.remove(f)
5 changes: 5 additions & 0 deletions tests/test_multiprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ def test_mark_process_dead_respects_lowercase(self):
# logic is tested elsewhere.
mark_process_dead(123)

def test_mark_process_dead_noop_when_path_unset(self):
os.environ.pop('prometheus_multiproc_dir', None)
os.environ.pop('PROMETHEUS_MULTIPROC_DIR', None)
mark_process_dead(123)


class TestMultiProcess(unittest.TestCase):
def setUp(self):
Expand Down