Skip to content

Commit

Permalink
exit program when threadcount is not 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Fengping Hu committed Nov 1, 2023
1 parent 52c0374 commit 8de362a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions prometheus/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 8de362a

Please sign in to comment.