- fixed loosing connection to Pot task
This commit is contained in:
+2
-1
@@ -61,7 +61,8 @@ class Window(QtWidgets.QMainWindow, Ui_MainWindow):
|
|||||||
|
|
||||||
def on_pot_changed(self, msg):
|
def on_pot_changed(self, msg):
|
||||||
print("on_pot_changed {}".format(msg))
|
print("on_pot_changed {}".format(msg))
|
||||||
if "Power" in msg:
|
for key in msg:
|
||||||
|
if "Power" in key:
|
||||||
self.lcdNumber_2.display(msg['Power'])
|
self.lcdNumber_2.display(msg['Power'])
|
||||||
|
|
||||||
def on_sensor_changed(self, msg):
|
def on_sensor_changed(self, msg):
|
||||||
|
|||||||
+6
-2
@@ -113,10 +113,13 @@ class MessageDispatcherSync(IConnection):
|
|||||||
|
|
||||||
async def on_connect(self):
|
async def on_connect(self):
|
||||||
if self.auto_subscribe:
|
if self.auto_subscribe:
|
||||||
|
asyncio.get_event_loop().run_in_executor(None, self.subscribe)
|
||||||
|
|
||||||
|
def subscribe(self):
|
||||||
for handler in self.msg_handlers:
|
for handler in self.msg_handlers:
|
||||||
key = handler.get_key()
|
key = handler.get_key()
|
||||||
print("Would subscribe {}".format(key))
|
print("Would subscribe {}".format(key))
|
||||||
asyncio.get_event_loop().run_in_executor(None, self.send, {'+': key})
|
self.send({'+': key})
|
||||||
|
|
||||||
async def on_disconnect(self):
|
async def on_disconnect(self):
|
||||||
pass
|
pass
|
||||||
@@ -132,7 +135,8 @@ class MessageDispatcherSync(IConnection):
|
|||||||
result = None
|
result = None
|
||||||
try:
|
try:
|
||||||
result = await asyncio.get_event_loop().run_in_executor(None, self.state.get, True, 1.0)
|
result = await asyncio.get_event_loop().run_in_executor(None, self.state.get, True, 1.0)
|
||||||
except:
|
print("Send subscribe {}".format(result))
|
||||||
|
except Exception as e:
|
||||||
pass
|
pass
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user