mirror of
https://github.com/home-assistant/core.git
synced 2025-07-11 15:27:08 +00:00
Small speed up to mqtt _async_queue_subscriptions (#118094)
This commit is contained in:
parent
09cbc35b46
commit
de275878c4
@ -452,7 +452,7 @@ class MQTT:
|
|||||||
self._should_reconnect: bool = True
|
self._should_reconnect: bool = True
|
||||||
self._available_future: asyncio.Future[bool] | None = None
|
self._available_future: asyncio.Future[bool] | None = None
|
||||||
|
|
||||||
self._max_qos: dict[str, int] = {} # topic, max qos
|
self._max_qos: defaultdict[str, int] = defaultdict(int) # topic, max qos
|
||||||
self._pending_subscriptions: dict[str, int] = {} # topic, qos
|
self._pending_subscriptions: dict[str, int] = {} # topic, qos
|
||||||
self._unsubscribe_debouncer = EnsureJobAfterCooldown(
|
self._unsubscribe_debouncer = EnsureJobAfterCooldown(
|
||||||
UNSUBSCRIBE_COOLDOWN, self._async_perform_unsubscribes
|
UNSUBSCRIBE_COOLDOWN, self._async_perform_unsubscribes
|
||||||
@ -820,8 +820,8 @@ class MQTT:
|
|||||||
"""Queue requested subscriptions."""
|
"""Queue requested subscriptions."""
|
||||||
for subscription in subscriptions:
|
for subscription in subscriptions:
|
||||||
topic, qos = subscription
|
topic, qos = subscription
|
||||||
max_qos = max(qos, self._max_qos.setdefault(topic, qos))
|
if (max_qos := self._max_qos[topic]) < qos:
|
||||||
self._max_qos[topic] = max_qos
|
self._max_qos[topic] = (max_qos := qos)
|
||||||
self._pending_subscriptions[topic] = max_qos
|
self._pending_subscriptions[topic] = max_qos
|
||||||
# Cancel any pending unsubscribe since we are subscribing now
|
# Cancel any pending unsubscribe since we are subscribing now
|
||||||
if topic in self._pending_unsubscribes:
|
if topic in self._pending_unsubscribes:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user