You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
552 B

import asyncio
import time
import socketio
async def main():
async with socketio.AsyncSimpleClient() as sio:
await sio.connect("http://localhost:5000")
while True:
start_timer = time.time()
await sio.emit("ping_from_client")
while (await sio.receive()) != ["pong_from_server"]:
pass
latency = time.time() - start_timer
print(f"latency is {latency * 1000:.2f} ms")
await asyncio.sleep(1)
if __name__ == "__main__":
asyncio.run(main())