fix: IP-independent pairing key fallback; run commands off the paho thread
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -18,6 +18,9 @@ import time
|
||||
import json
|
||||
import logging
|
||||
import paho.mqtt.client as mqtt
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
|
||||
worker = ThreadPoolExecutor(max_workers=1)
|
||||
|
||||
# --- Config ---
|
||||
MQTT_HOST = "192.168.0.154" # CT 301 Mosquitto
|
||||
@@ -110,6 +113,13 @@ def on_connect(client, userdata, flags, rc):
|
||||
|
||||
|
||||
def on_message(client, userdata, msg):
|
||||
# Hand off to one worker thread: an `off` can block up to 60s, which starves
|
||||
# paho's keepalive (broker drops us, queued commands are lost). The single
|
||||
# worker keeps commands in order.
|
||||
worker.submit(safe_handle, client, msg)
|
||||
|
||||
|
||||
def safe_handle(client, msg):
|
||||
# An exception escaping a paho callback kills the network thread while the
|
||||
# poll loop keeps the process alive — a silent zombie systemd never restarts.
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user