Websocket server not async? - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Networking (https://python-forum.io/forum-12.html) +--- Thread: Websocket server not async? (/thread-21292.html) |
Websocket server not async? - korenron - Sep-23-2019 Hello , I have a wroking websocket server that my application connected to him and send data to the server. my problem is that sometime the APP send 5-6 messages , while my code didn't finish the first request yet. so I can see it "running over" and make a lot of mess :-) is there any way to tell him to wait until finish , then read the next one? I don't mind him to ignore the messges until he finsih this is what I have async def hello(websocket, path): global OldClientRespone print("--------------------------->" + OldClientRespone) ClientResponse = await websocket.recv() print ("OLD is - " + OldClientRespone+ "\r\nNew is " + ClientResponse) ## some code that take about 5 seconds to be finish start_server = websockets.serve(hello, '10.0.0.100', 1234) asyncio.get_event_loop().run_until_complete(start_server) asyncio.get_event_loop().run_forever()Thanks, |