mirror of
https://github.com/home-assistant/core.git
synced 2025-08-30 18:01:31 +02:00
Skip NextBus update if integration is still loading (#123564)
* Skip NextBus update if integration is still loading Fixes a race between the loading thread and update thread leading to an unrecoverable error * Use async_at_started * Use local copy of _route_stops to avoid NextBus race condition * Update homeassistant/components/nextbus/coordinator.py --------- Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
This commit is contained in:
committed by
Paulus Schoutsen
parent
a2027fc78c
commit
e2c1a38d87
@@ -50,13 +50,15 @@ class NextBusDataUpdateCoordinator(DataUpdateCoordinator):
|
|||||||
|
|
||||||
async def _async_update_data(self) -> dict[str, Any]:
|
async def _async_update_data(self) -> dict[str, Any]:
|
||||||
"""Fetch data from NextBus."""
|
"""Fetch data from NextBus."""
|
||||||
self.logger.debug("Updating data from API. Routes: %s", str(self._route_stops))
|
|
||||||
|
_route_stops = set(self._route_stops)
|
||||||
|
self.logger.debug("Updating data from API. Routes: %s", str(_route_stops))
|
||||||
|
|
||||||
def _update_data() -> dict:
|
def _update_data() -> dict:
|
||||||
"""Fetch data from NextBus."""
|
"""Fetch data from NextBus."""
|
||||||
self.logger.debug("Updating data from API (executor)")
|
self.logger.debug("Updating data from API (executor)")
|
||||||
predictions: dict[RouteStop, dict[str, Any]] = {}
|
predictions: dict[RouteStop, dict[str, Any]] = {}
|
||||||
for route_stop in self._route_stops:
|
for route_stop in _route_stops:
|
||||||
prediction_results: list[dict[str, Any]] = []
|
prediction_results: list[dict[str, Any]] = []
|
||||||
try:
|
try:
|
||||||
prediction_results = self.client.predictions_for_stop(
|
prediction_results = self.client.predictions_for_stop(
|
||||||
|
Reference in New Issue
Block a user