api: automatically rediscover locks from CCUJack
All checks were successful
Build Container / Build Container (push) Successful in 1m35s
All checks were successful
Build Container / Build Container (push) Successful in 1m35s
closes CCCHH/dooris#5
This commit is contained in:
parent
b1b624a7b3
commit
2349e58924
3 changed files with 24 additions and 5 deletions
|
|
@ -3,7 +3,7 @@
|
|||
# https://github.com/eclipse-paho/paho.mqtt.python/blob/master/examples/loop_asyncio.py
|
||||
#
|
||||
|
||||
from typing import Any, List, Set, Iterable
|
||||
from typing import Any, Set, Iterable
|
||||
import logging
|
||||
import asyncio
|
||||
import socket
|
||||
|
|
@ -132,6 +132,7 @@ class AsyncMqttClient:
|
|||
self.fut_subscribe = asyncio.get_running_loop().create_future()
|
||||
self.client.subscribe([(i, qos) for i in to_add])
|
||||
await self.fut_subscribe
|
||||
self.active_subscriptions.update(to_add)
|
||||
|
||||
to_remove = self.active_subscriptions.difference(topics)
|
||||
if to_remove:
|
||||
|
|
@ -139,6 +140,7 @@ class AsyncMqttClient:
|
|||
self.fut_unsubscribe = asyncio.get_running_loop().create_future()
|
||||
self.client.unsubscribe(list(to_remove))
|
||||
await self.fut_unsubscribe
|
||||
self.active_subscriptions.difference_update(to_remove)
|
||||
|
||||
async def connect(self):
|
||||
server_host, server_port = self.connection_string.rsplit(":", maxsplit=1)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue