From 06818fd14d7351a50c7aa2de6feeb84f537be0e1 Mon Sep 17 00:00:00 2001 From: Fengping Hu Date: Wed, 1 Nov 2023 12:48:51 -0500 Subject: [PATCH] exit program when threadcount is not 2 --- prometheus/exporter.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/prometheus/exporter.py b/prometheus/exporter.py index ba9087d..7b4c811 100644 --- a/prometheus/exporter.py +++ b/prometheus/exporter.py @@ -5,6 +5,8 @@ from subprocess import check_call from prometheus_client import start_http_server, Gauge, Enum import requests +import threading +import sys class AppMetrics: @@ -37,6 +39,10 @@ def run_metrics_loop(self): """Metrics fetching loop""" while True: + if threading.active_count() != 2: + print(f"Unexpected threadcount: {threading.active_count()}, so exit the program") + sys.exit(1) + self.fetch() time.sleep(self.polling_interval_seconds)