From 3078d125e881897c1a2cd95e8ad4f5e3077745fd Mon Sep 17 00:00:00 2001 From: Johannes Findeisen Date: Wed, 22 Feb 2023 17:14:02 +0100 Subject: [PATCH] Use signal.pause() instead of while True to keep Linspector running. A while True loop starts using 100% of one CPU when there is no sleep() inserted. That's not a good way to keep a program running. (0.20.3) --- bin/linspector | 6 +++--- linspector/core/linspectord.py | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/bin/linspector b/bin/linspector index d5c6977..c765948 100755 --- a/bin/linspector +++ b/bin/linspector @@ -8,6 +8,7 @@ See LICENSE.txt (MIT license). # Only exit execution on critical core errors. Do not exit when monitors are failing on # configuration and execution, but log these errors. import argparse +import signal import sys from linspector.core.configuration import Configuration @@ -16,7 +17,7 @@ from linspector.core.linspector import Linspector from linspector.core.logger import Log from linspector.core.monitors import Monitors -__version__ = '0.20.2' +__version__ = '0.20.3' __author__ = 'Johannes Findeisen ' @@ -101,8 +102,7 @@ def main(): sys.exit(1) else: try: - while True: - pass + signal.pause() except KeyboardInterrupt: log.info('[linspector] program terminated by user!') diff --git a/linspector/core/linspectord.py b/linspector/core/linspectord.py index 1b6c9c7..0b98f4b 100644 --- a/linspector/core/linspectord.py +++ b/linspector/core/linspectord.py @@ -129,5 +129,4 @@ class Linspectord: # while development because the daemon even runs when internally is nothing to do. @staticmethod def run(): - while True: - pass + signal.pause()