Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Websocket server not async?
#1
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,
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  define a variable before looped websocket korenron 0 200 Sep-22-2019, 12:53 PM
Last Post: korenron
  Async socket server and ports Pengwyn 1 639 Feb-28-2019, 12:13 AM
Last Post: DeaD_EyE
  need to understand better __setup__.py, websocket-client, packaging penright 0 829 Jul-08-2018, 09:40 PM
Last Post: penright
  Pro's and Con's of some different websocket libraries penright 0 610 Jun-29-2018, 12:07 PM
Last Post: penright

Forum Jump:


Users browsing this thread: 1 Guest(s)