Do not timeout if only asked to you
This commit is contained in:
@@ -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...")
|
||||
|
||||
Reference in New Issue
Block a user