Pass tasks instead of coros to asyncio.wait in forked_daapd (#78462)

* Remove coroutines from asyncio.wait in forked_daapd

* Update homeassistant/components/forked_daapd/media_player.py

Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>

Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
This commit is contained in:
uvjustin 2022-09-14 21:49:00 +08:00 committed by GitHub
parent 219cee2ca9
commit 855b0dfdba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -418,15 +418,17 @@ class ForkedDaapdMaster(MediaPlayerEntity):
# restore state # restore state
await self._api.set_volume(volume=self._last_volume * 100) await self._api.set_volume(volume=self._last_volume * 100)
if self._last_outputs: if self._last_outputs:
futures = [] futures: list[asyncio.Task[int]] = []
for output in self._last_outputs: for output in self._last_outputs:
futures.append( futures.append(
asyncio.create_task(
self._api.change_output( self._api.change_output(
output["id"], output["id"],
selected=output["selected"], selected=output["selected"],
volume=output["volume"], volume=output["volume"],
) )
) )
)
await asyncio.wait(futures) await asyncio.wait(futures)
else: # enable all outputs else: # enable all outputs
await self._api.set_enabled_outputs( await self._api.set_enabled_outputs(