Python 3.11 compatibility.

https://docs.python.org/3/library/asyncio-task.html#asyncio.wait says:

> Changed in version 3.11: Passing coroutine objects to wait() directly
> is forbidden.
This commit is contained in:
Dan Albert 2022-12-29 17:25:49 -08:00
parent 7167e84a8f
commit a1af4e563a

View File

@ -1,3 +1,4 @@
import asyncio
from asyncio import wait
from fastapi import APIRouter, WebSocket
@ -30,7 +31,9 @@ class ConnectionManager:
async def broadcast(self, events: GameUpdateEventsJs) -> None:
futures = []
for connection in self.active_connections:
futures.append(connection.send_json(jsonable_encoder(events)))
futures.append(
asyncio.create_task(connection.send_json(jsonable_encoder(events)))
)
await wait(futures)