mirror of
https://github.com/GNS3/gns3-server.git
synced 2025-06-14 21:38:19 +00:00
Fix broken websocket console with Python 3.11
This commit is contained in:
@ -469,7 +469,18 @@ class BaseNode:
|
||||
|
||||
try:
|
||||
# keep forwarding websocket data in both direction
|
||||
await asyncio.wait([ws_forward(telnet_writer), telnet_forward(telnet_reader)], return_when=asyncio.FIRST_COMPLETED)
|
||||
if sys.version_info >= (3, 11, 0):
|
||||
# Starting with Python 3.11, passing coroutine objects to wait() directly is forbidden.
|
||||
aws = [asyncio.create_task(ws_forward(telnet_writer)), asyncio.create_task(telnet_forward(telnet_reader))]
|
||||
else:
|
||||
aws = [ws_forward(telnet_writer), telnet_forward(telnet_reader)]
|
||||
|
||||
done, pending = await asyncio.wait(aws, return_when=asyncio.FIRST_COMPLETED)
|
||||
for task in done:
|
||||
if task.exception():
|
||||
log.warning(f"Exception while forwarding WebSocket data to Telnet server {task.exception()}")
|
||||
for task in pending:
|
||||
task.cancel()
|
||||
finally:
|
||||
log.info("Client has disconnected from console WebSocket")
|
||||
if not ws.closed:
|
||||
|
Reference in New Issue
Block a user