1
mirror of https://github.com/home-assistant/core synced 2024-08-02 23:40:32 +02:00

Ensure event listener integrations do the queue insert as a callback (#42265)

This commit is contained in:
J. Nick Koston 2020-10-23 10:38:46 -05:00 committed by GitHub
parent 5dac3883b0
commit 5bba299e8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 0 deletions

View File

@ -26,6 +26,7 @@ from homeassistant.const import (
STATE_UNAVAILABLE,
STATE_UNKNOWN,
)
from homeassistant.core import callback
from homeassistant.helpers import event as event_helper, state as state_helper
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity_values import EntityValues
@ -500,6 +501,7 @@ class InfluxThread(threading.Thread):
self.shutdown = False
hass.bus.listen(EVENT_STATE_CHANGED, self._event_listener)
@callback
def _event_listener(self, event):
"""Listen for new messages on the bus and queue them for Influx."""
item = (time.monotonic(), event)

View File

@ -21,6 +21,7 @@ from homeassistant.const import (
STATE_UNAVAILABLE,
STATE_UNKNOWN,
)
from homeassistant.core import callback
from homeassistant.helpers import state as state_helper
import homeassistant.helpers.config_validation as cv
@ -165,6 +166,7 @@ class WatsonIOTThread(threading.Thread):
self.shutdown = False
hass.bus.listen(EVENT_STATE_CHANGED, self._event_listener)
@callback
def _event_listener(self, event):
"""Listen for new messages on the bus and queue them for Watson IoT."""
item = (time.monotonic(), event)

View File

@ -22,6 +22,7 @@ from homeassistant.const import (
STATE_UNAVAILABLE,
STATE_UNKNOWN,
)
from homeassistant.core import callback
from homeassistant.helpers import event as event_helper, state as state_helper
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entityfilter import (
@ -186,6 +187,7 @@ class ZabbixThread(threading.Thread):
self.queue.put(None)
self.join()
@callback
def _event_listener(self, event):
"""Listen for new messages on the bus and queue them for Zabbix."""
item = (time.monotonic(), event)