mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 08:47:57 +00:00
Fix the radio browser doing I/O in the event loop (#118842)
This commit is contained in:
parent
678c06beb3
commit
72309364f5
@ -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(
|
||||
|
Loading…
x
Reference in New Issue
Block a user