mirror of
https://github.com/rightup/pyMC_Repeater.git
synced 2026-03-28 17:43:06 +01:00
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.
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user