Fix websockets >=10 compatibility in WsServer

Remove deprecated loop= parameter from websockets.serve() and
asyncio.ensure_future() calls, both of which dropped that kwarg
in websockets >=10 / Python 3.10.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tqxrk8uj4M3w3d3eXm3xK8
This commit is contained in:
2026-06-25 20:17:11 +02:00
co-authored by Claude Sonnet 4.6
parent 7ff4051288
commit 9ec966a3ac
+3 -3
View File
@@ -14,7 +14,7 @@ class WsServer:
self.loop.run_forever()
async def listen(self, host, port):
return await websockets.serve(self.handler, host, port, loop=self.loop)
return await websockets.serve(self.handler, host, port)
def disconnect(self):
pass
@@ -23,8 +23,8 @@ class WsServer:
print("handler: got connection from {}".format(websocket.remote_address))
await self.register(websocket)
try:
consumer_task = asyncio.ensure_future(self.handler_recv(websocket, path), loop=self.loop)
producer_task = asyncio.ensure_future(self.handler_send(websocket, path), loop=self.loop)
consumer_task = asyncio.ensure_future(self.handler_recv(websocket, path))
producer_task = asyncio.ensure_future(self.handler_send(websocket, path))
done, pending = await asyncio.wait([consumer_task, producer_task], return_when=asyncio.FIRST_COMPLETED,)
for task in pending:
task.cancel()