From e14fd3feeac242a63c6c4cef2a39ff905d82fa22 Mon Sep 17 00:00:00 2001 From: agessaman Date: Sat, 21 Feb 2026 08:19:00 -0800 Subject: [PATCH] Refactor noise floor retrieval in RepeaterHandler to use asyncio executor - Updated the noise floor retrieval method to run in an executor, preventing blocking of the event loop during the KISS modem's command execution. - This change enhances responsiveness by allowing the process to handle other tasks while waiting for the noise floor measurement. --- repeater/engine.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/repeater/engine.py b/repeater/engine.py index 8d891cd..47cf667 100644 --- a/repeater/engine.py +++ b/repeater/engine.py @@ -874,7 +874,10 @@ class RepeaterHandler(BaseHandler): return try: - noise_floor = self.get_noise_floor() + # Run in executor so KISS modem's blocking _send_command (up to 5s timeout) + # does not block the event loop and hang the process / delay Ctrl+C. + loop = asyncio.get_running_loop() + noise_floor = await loop.run_in_executor(None, self.get_noise_floor) if noise_floor is not None: self.storage.record_noise_floor(noise_floor) logger.debug(f"Recorded noise floor: {noise_floor} dBm")