Python Forum
Websocket server not async?
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,
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  websocket help johnbob 0 631 Jan-13-2024, 06:32 AM
Last Post: johnbob
  Paramiko Server -- Exception (server): Error reading SSH protocol banner ujlain 3 4,277 Jul-24-2023, 06:52 AM
Last Post: Gribouillis
  trying to stream data from a websocket to client tomtom 2 1,980 Jan-12-2023, 03:01 PM
Last Post: Vadanane
  Help with Websocket-Client Module - Infinite Loop CluelessChris 0 3,885 Apr-25-2021, 01:53 PM
Last Post: CluelessChris
  Websocket conection closes abnormally Joshua_Omolo 2 3,819 Feb-17-2021, 08:03 AM
Last Post: Joshua_Omolo
  define a variable before looped websocket korenron 0 1,819 Sep-22-2019, 12:53 PM
Last Post: korenron
  Async socket server and ports Pengwyn 1 10,713 Feb-28-2019, 12:13 AM
Last Post: DeaD_EyE
  need to understand better __setup__.py, websocket-client, packaging penright 0 2,928 Jul-08-2018, 09:40 PM
Last Post: penright
  Pro's and Con's of some different websocket libraries penright 0 2,336 Jun-29-2018, 12:07 PM
Last Post: penright

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020