From 72309364f5848acc24793a5b7156d66c589183da Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Tue, 4 Jun 2024 23:59:25 -0400 Subject: [PATCH] Fix the radio browser doing I/O in the event loop (#118842) --- homeassistant/components/radio_browser/media_source.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/homeassistant/components/radio_browser/media_source.py b/homeassistant/components/radio_browser/media_source.py index d23d09cce3a..2f95acf407d 100644 --- a/homeassistant/components/radio_browser/media_source.py +++ b/homeassistant/components/radio_browser/media_source.py @@ -5,6 +5,7 @@ from __future__ import annotations import mimetypes from radios import FilterBy, Order, RadioBrowser, Station +from radios.radio_browser import pycountry from homeassistant.components.media_player import MediaClass, MediaType from homeassistant.components.media_source.error import Unresolvable @@ -145,6 +146,8 @@ class RadioMediaSource(MediaSource): # We show country in the root additionally, when there is no item if not item.identifier or category == "country": + # Trigger the lazy loading of the country database to happen inside the executor + await self.hass.async_add_executor_job(lambda: len(pycountry.countries)) countries = await radios.countries(order=Order.NAME) return [ BrowseMediaSource(