#๐Ÿ”’ Websockets message receiving blocks event loop

7 messages ยท Page 1 of 1 (latest)

rigid berry
#

Hey, I've been trying to wrap my head around this for like a while now. I have a websockets server, which handles connections (ofcourse lol). It seems that the code is blocking? Even though it shouldn't be:

async def handle_client(websocket, path):
    try:
        await websocket.send(json.dumps({"event": events.HeartBeatEvent, "args": []}))
        async for message in websocket:
            data = json.loads(message)
            if "event" not in data:
                continue
            event = data["event"]
            await handle_panel_request(websocket, event, data["args"])
    finally:
        print("conection lost")

I never get the connection lost print message, even though I've clearly disconnected from the connection client-side, also any other clients can't connect to it.

grand heronBOT
#

@rigid berry

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

rigid berry
#

After I exit (using Ctrl + C), I do get all of the connections (I did a print statement above try) and also the connection lost ones

rigid berry
#

found the issue, not related to websockets at all

#

!close

grand heronBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.