mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Minor cleanup of MQTT ACK handling (#39217)
This commit is contained in:
parent
bee6d87e7a
commit
b1c0d8fb6c
@ -938,7 +938,10 @@ class MQTT:
|
|||||||
"""Publish / Subscribe / Unsubscribe callback."""
|
"""Publish / Subscribe / Unsubscribe callback."""
|
||||||
self.hass.add_job(self._mqtt_handle_mid, mid)
|
self.hass.add_job(self._mqtt_handle_mid, mid)
|
||||||
|
|
||||||
async def _mqtt_handle_mid(self, mid) -> None:
|
@callback
|
||||||
|
def _mqtt_handle_mid(self, mid) -> None:
|
||||||
|
# Create the mid event if not created, either _mqtt_handle_mid or _wait_for_mid
|
||||||
|
# may be executed first.
|
||||||
if mid not in self._pending_operations:
|
if mid not in self._pending_operations:
|
||||||
self._pending_operations[mid] = asyncio.Event()
|
self._pending_operations[mid] = asyncio.Event()
|
||||||
self._pending_operations[mid].set()
|
self._pending_operations[mid].set()
|
||||||
@ -956,6 +959,8 @@ class MQTT:
|
|||||||
|
|
||||||
async def _wait_for_mid(self, mid):
|
async def _wait_for_mid(self, mid):
|
||||||
"""Wait for ACK from broker."""
|
"""Wait for ACK from broker."""
|
||||||
|
# Create the mid event if not created, either _mqtt_handle_mid or _wait_for_mid
|
||||||
|
# may be executed first.
|
||||||
if mid not in self._pending_operations:
|
if mid not in self._pending_operations:
|
||||||
self._pending_operations[mid] = asyncio.Event()
|
self._pending_operations[mid] = asyncio.Event()
|
||||||
try:
|
try:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user