Skip to content

Commit

Permalink
fix websocket_server.py to work with python 3.12
Browse files Browse the repository at this point in the history
  • Loading branch information
arvidn committed Nov 16, 2024
1 parent dea2b30 commit 699c9d4
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions test/websocket_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ async def handle(websocket, path):
print(e)


if __name__ == '__main__':
async def main() -> None:
port = int(sys.argv[1])
use_ssl = sys.argv[2] != '0'
min_interval = sys.argv[3]
Expand All @@ -52,6 +52,9 @@ async def handle(websocket, path):
else:
ssl_context = None

start_server = websockets.serve(handle, '127.0.0.1', port, ssl=ssl_context)
asyncio.get_event_loop().run_until_complete(start_server)
await websockets.serve(handle, '127.0.0.1', port, ssl=ssl_context)

if __name__ == '__main__':
loop = asyncio.get_event_loop()
asyncio.get_event_loop().run_until_complete(main())
asyncio.get_event_loop().run_forever()

0 comments on commit 699c9d4

Please sign in to comment.