mirror of
https://github.com/home-assistant/core
synced 2024-09-09 12:51:22 +02:00
Ensure event listener integrations do the queue insert as a callback (#42265)
This commit is contained in:
parent
5dac3883b0
commit
5bba299e8f
@ -26,6 +26,7 @@ from homeassistant.const import (
|
|||||||
STATE_UNAVAILABLE,
|
STATE_UNAVAILABLE,
|
||||||
STATE_UNKNOWN,
|
STATE_UNKNOWN,
|
||||||
)
|
)
|
||||||
|
from homeassistant.core import callback
|
||||||
from homeassistant.helpers import event as event_helper, state as state_helper
|
from homeassistant.helpers import event as event_helper, state as state_helper
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.entity_values import EntityValues
|
from homeassistant.helpers.entity_values import EntityValues
|
||||||
@ -500,6 +501,7 @@ class InfluxThread(threading.Thread):
|
|||||||
self.shutdown = False
|
self.shutdown = False
|
||||||
hass.bus.listen(EVENT_STATE_CHANGED, self._event_listener)
|
hass.bus.listen(EVENT_STATE_CHANGED, self._event_listener)
|
||||||
|
|
||||||
|
@callback
|
||||||
def _event_listener(self, event):
|
def _event_listener(self, event):
|
||||||
"""Listen for new messages on the bus and queue them for Influx."""
|
"""Listen for new messages on the bus and queue them for Influx."""
|
||||||
item = (time.monotonic(), event)
|
item = (time.monotonic(), event)
|
||||||
|
@ -21,6 +21,7 @@ from homeassistant.const import (
|
|||||||
STATE_UNAVAILABLE,
|
STATE_UNAVAILABLE,
|
||||||
STATE_UNKNOWN,
|
STATE_UNKNOWN,
|
||||||
)
|
)
|
||||||
|
from homeassistant.core import callback
|
||||||
from homeassistant.helpers import state as state_helper
|
from homeassistant.helpers import state as state_helper
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
|
||||||
@ -165,6 +166,7 @@ class WatsonIOTThread(threading.Thread):
|
|||||||
self.shutdown = False
|
self.shutdown = False
|
||||||
hass.bus.listen(EVENT_STATE_CHANGED, self._event_listener)
|
hass.bus.listen(EVENT_STATE_CHANGED, self._event_listener)
|
||||||
|
|
||||||
|
@callback
|
||||||
def _event_listener(self, event):
|
def _event_listener(self, event):
|
||||||
"""Listen for new messages on the bus and queue them for Watson IoT."""
|
"""Listen for new messages on the bus and queue them for Watson IoT."""
|
||||||
item = (time.monotonic(), event)
|
item = (time.monotonic(), event)
|
||||||
|
@ -22,6 +22,7 @@ from homeassistant.const import (
|
|||||||
STATE_UNAVAILABLE,
|
STATE_UNAVAILABLE,
|
||||||
STATE_UNKNOWN,
|
STATE_UNKNOWN,
|
||||||
)
|
)
|
||||||
|
from homeassistant.core import callback
|
||||||
from homeassistant.helpers import event as event_helper, state as state_helper
|
from homeassistant.helpers import event as event_helper, state as state_helper
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.entityfilter import (
|
from homeassistant.helpers.entityfilter import (
|
||||||
@ -186,6 +187,7 @@ class ZabbixThread(threading.Thread):
|
|||||||
self.queue.put(None)
|
self.queue.put(None)
|
||||||
self.join()
|
self.join()
|
||||||
|
|
||||||
|
@callback
|
||||||
def _event_listener(self, event):
|
def _event_listener(self, event):
|
||||||
"""Listen for new messages on the bus and queue them for Zabbix."""
|
"""Listen for new messages on the bus and queue them for Zabbix."""
|
||||||
item = (time.monotonic(), event)
|
item = (time.monotonic(), event)
|
||||||
|
Loading…
Reference in New Issue
Block a user