I am trying to access a websocket to listen to some information and so I want to use the run_forever command to keep listening until I stop the program, but when I do I get the error below, could someone tell me what I am doing wrong?
Code:
loop = asyncio.get_event_loop() async def listen(): url = "websocket url starting with wss" async with websockets.connect(url) as ws: msg = await ws.recv() print(msg) loop.run_forever(listen()) the error then says:
RuntimeWarning: coroutine 'listen' was never awaited loop.run_forever(listen()) RuntimeWarning: Enable tracemalloc to get the object allocation traceback Traceback (most recent call last): File "C:\Users\...", line 18, in <module> loop.run_forever(listen()) TypeError: run_forever() takes 1 positional argument but 2 were given
run_forever. Tryrun_forever(listen)