- fixed loosing connection to Pot task

This commit is contained in:
jens
2020-12-02 17:19:12 +01:00
parent 6a6ca8c92d
commit b5cdb1a973
2 changed files with 12 additions and 7 deletions
+9 -5
View File
@@ -113,10 +113,13 @@ class MessageDispatcherSync(IConnection):
async def on_connect(self):
if self.auto_subscribe:
for handler in self.msg_handlers:
key = handler.get_key()
print("Would subscribe {}".format(key))
asyncio.get_event_loop().run_in_executor(None, self.send, {'+': key})
asyncio.get_event_loop().run_in_executor(None, self.subscribe)
def subscribe(self):
for handler in self.msg_handlers:
key = handler.get_key()
print("Would subscribe {}".format(key))
self.send({'+': key})
async def on_disconnect(self):
pass
@@ -132,7 +135,8 @@ class MessageDispatcherSync(IConnection):
result = None
try:
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
return result