termination mechanism integrated
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
import paho.mqtt.client as mqtt
|
||||
import threading
|
||||
from threading import Event
|
||||
from loguru import logger
|
||||
from AbstractMqttHandler import AbstractMqttPublisher
|
||||
from time import sleep
|
||||
|
||||
def mqttPeriodPublisherStart(config, processImage):
|
||||
mqttPeriodPublisherThread = MqttPeriodPublisher(config, processImage)
|
||||
@@ -14,7 +12,7 @@ class MqttPeriodPublisher(AbstractMqttPublisher):
|
||||
super().__init__(config, processImage)
|
||||
|
||||
def localLoop(self):
|
||||
while True:
|
||||
while not self.killBill:
|
||||
with self.processImage:
|
||||
if not self.processImage.isInitialized():
|
||||
continue
|
||||
@@ -28,5 +26,5 @@ class MqttPeriodPublisher(AbstractMqttPublisher):
|
||||
self.client.publish("{}/{}".format(self.config["analogInputPeriodicTopicPrefix"], str(analogInputItem[0])),
|
||||
str(analogInputItem[1]))
|
||||
|
||||
sleep(float(self.config["analogInputPublishPeriod"]))
|
||||
self.killEvent.wait(timeout=float(self.config["analogInputPublishPeriod"]))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user