mirror of
https://github.com/home-assistant/core.git
synced 2025-07-28 07:37:34 +00:00
Fix matrix blocking call by running sync_forever in background_task (#122800)
Fix blocking call by running sync_forever in background_task
This commit is contained in:
parent
7f4dabf546
commit
e0a1aaa1b9
@ -209,15 +209,22 @@ class MatrixBot:
|
|||||||
await self._resolve_room_aliases(listening_rooms)
|
await self._resolve_room_aliases(listening_rooms)
|
||||||
self._load_commands(commands)
|
self._load_commands(commands)
|
||||||
await self._join_rooms()
|
await self._join_rooms()
|
||||||
|
|
||||||
# Sync once so that we don't respond to past events.
|
# Sync once so that we don't respond to past events.
|
||||||
|
_LOGGER.debug("Starting initial sync for %s", self._mx_id)
|
||||||
await self._client.sync(timeout=30_000)
|
await self._client.sync(timeout=30_000)
|
||||||
|
_LOGGER.debug("Finished initial sync for %s", self._mx_id)
|
||||||
|
|
||||||
self._client.add_event_callback(self._handle_room_message, RoomMessageText)
|
self._client.add_event_callback(self._handle_room_message, RoomMessageText)
|
||||||
|
|
||||||
await self._client.sync_forever(
|
_LOGGER.debug("Starting sync_forever for %s", self._mx_id)
|
||||||
timeout=30_000,
|
self.hass.async_create_background_task(
|
||||||
loop_sleep_time=1_000,
|
self._client.sync_forever(
|
||||||
) # milliseconds.
|
timeout=30_000,
|
||||||
|
loop_sleep_time=1_000,
|
||||||
|
), # milliseconds.
|
||||||
|
name=f"{self.__class__.__name__}: sync_forever for '{self._mx_id}'",
|
||||||
|
)
|
||||||
|
|
||||||
self.hass.bus.async_listen_once(EVENT_HOMEASSISTANT_START, handle_startup)
|
self.hass.bus.async_listen_once(EVENT_HOMEASSISTANT_START, handle_startup)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user