Retrieve friends in an async manner in Lastfm (#94255)

This commit is contained in:
Joost Lekkerkerker 2023-06-08 15:55:09 +02:00 committed by GitHub
parent 77badafea1
commit 425c964898
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -128,9 +128,12 @@ class LastFmConfigFlowHandler(ConfigFlow, domain=DOMAIN):
main_user, _ = get_lastfm_user( main_user, _ = get_lastfm_user(
self.data[CONF_API_KEY], self.data[CONF_MAIN_USER] self.data[CONF_API_KEY], self.data[CONF_MAIN_USER]
) )
friends_response = await self.hass.async_add_executor_job(
main_user.get_friends
)
friends = [ friends = [
SelectOptionDict(value=friend.name, label=friend.get_name(True)) SelectOptionDict(value=friend.name, label=friend.get_name(True))
for friend in main_user.get_friends() for friend in friends_response
] ]
except WSError: except WSError:
friends = [] friends = []
@ -197,9 +200,12 @@ class LastFmOptionsFlowHandler(OptionsFlowWithConfigEntry):
self.options[CONF_API_KEY], self.options[CONF_API_KEY],
self.options[CONF_MAIN_USER], self.options[CONF_MAIN_USER],
) )
friends_response = await self.hass.async_add_executor_job(
main_user.get_friends
)
friends = [ friends = [
SelectOptionDict(value=friend.name, label=friend.get_name(True)) SelectOptionDict(value=friend.name, label=friend.get_name(True))
for friend in main_user.get_friends() for friend in friends_response
] ]
except WSError: except WSError:
friends = [] friends = []