mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Add comment to explain not using the core API in MQTT client (#108942)
This commit is contained in:
parent
dec9eb9ae4
commit
677b06f502
@ -216,6 +216,10 @@ def subscribe(
|
|||||||
|
|
||||||
def remove() -> None:
|
def remove() -> None:
|
||||||
"""Remove listener convert."""
|
"""Remove listener convert."""
|
||||||
|
# MQTT messages tend to be high volume,
|
||||||
|
# and since they come in via a thread and need to be processed in the event loop,
|
||||||
|
# we want to avoid hass.add_job since most of the time is spent calling
|
||||||
|
# inspect to figure out how to run the callback.
|
||||||
hass.loop.call_soon_threadsafe(async_remove)
|
hass.loop.call_soon_threadsafe(async_remove)
|
||||||
|
|
||||||
return remove
|
return remove
|
||||||
@ -796,6 +800,10 @@ class MQTT:
|
|||||||
self, _mqttc: mqtt.Client, _userdata: None, msg: mqtt.MQTTMessage
|
self, _mqttc: mqtt.Client, _userdata: None, msg: mqtt.MQTTMessage
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Message received callback."""
|
"""Message received callback."""
|
||||||
|
# MQTT messages tend to be high volume,
|
||||||
|
# and since they come in via a thread and need to be processed in the event loop,
|
||||||
|
# we want to avoid hass.add_job since most of the time is spent calling
|
||||||
|
# inspect to figure out how to run the callback.
|
||||||
self.loop.call_soon_threadsafe(self._mqtt_handle_message, msg)
|
self.loop.call_soon_threadsafe(self._mqtt_handle_message, msg)
|
||||||
|
|
||||||
@lru_cache(None) # pylint: disable=method-cache-max-size-none
|
@lru_cache(None) # pylint: disable=method-cache-max-size-none
|
||||||
|
Loading…
x
Reference in New Issue
Block a user