From bcc3670aff6ba8329cc6f2fab7f399f013e7da14 Mon Sep 17 00:00:00 2001 From: Matthias Guillitte Date: Mon, 17 Aug 2026 23:03:34 +0200 Subject: [PATCH] Do not timeout if only asked to you --- orchestrateur/main.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/orchestrateur/main.py b/orchestrateur/main.py index 1b924f3..569fd44 100644 --- a/orchestrateur/main.py +++ b/orchestrateur/main.py @@ -618,13 +618,14 @@ async def process_messages_task(): endpoint = data.get("endpoint") if endpoint: # Schedule as a background task so processing the queue isn't stalled - asyncio.create_task(handle_telemetry_request(endpoint)) + do_timeout = topic == "cmd/all" + asyncio.create_task(handle_telemetry_request(endpoint, do_timeout=do_timeout)) else: print("[CloudMQTT] Received 'request_telemetry' but missing 'endpoint' field.") else: print(f"[CloudMQTT] Unknown action: {action}") -async def handle_telemetry_request(endpoint: str): +async def handle_telemetry_request(endpoint: str, do_timeout=True): """ Task to gather telemetry data (including structured systemd logs) and post it to the target HTTP endpoint. @@ -654,9 +655,10 @@ async def handle_telemetry_request(endpoint: str): ) # 4. Wait for he microwave turn to send the telemetry data to the cloud endpoint - timeout = int(DEVICE_ID.split("_")[-1]) * config.TELEMETRY_SEND_INTERVAL - print(f"[Telemetry] Waiting for {timeout}s before sending telemetry to avoid collisions...") - await asyncio.sleep(timeout) + if do_timeout: + do_timeout = int(DEVICE_ID.split("_")[-1]) * config.TELEMETRY_SEND_INTERVAL + print(f"[Telemetry] Waiting for {do_timeout}s before sending telemetry to avoid collisions...") + await asyncio.sleep(do_timeout) # 5. Offload blocking HTTP POST to thread pool print(f"[Telemetry] Sending payload with {len(logs_list)} log entries...")