mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +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
|
import mimetypes
|
||||||
|
|
||||||
from radios import FilterBy, Order, RadioBrowser, Station
|
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_player import MediaClass, MediaType
|
||||||
from homeassistant.components.media_source.error import Unresolvable
|
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
|
# We show country in the root additionally, when there is no item
|
||||||
if not item.identifier or category == "country":
|
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)
|
countries = await radios.countries(order=Order.NAME)
|
||||||
return [
|
return [
|
||||||
BrowseMediaSource(
|
BrowseMediaSource(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user