Wytamma / beastiary

Real time and remote MCMC trace monitoring with BEASTIARY.
https://beastiary.wytamma.com
20 stars 2 forks source link

WebSockets for Continuous Data Transmission #38

Open Wytamma opened 8 months ago

Wytamma commented 8 months ago

Replace polling with web sockets e.g.

from fastapi import FastAPI, WebSocket

app = FastAPI()

@app.websocket("/data")
async def data_websocket(websocket: WebSocket):
    await websocket.accept()
    while True:
        data = await generate_data()  # Your function to get real-time data
        await websocket.send_json(data)
        await asyncio.sleep(1)  # Adjust based on desired update frequency
Wytamma commented 7 months ago

What will happen if the frontend gets out of sync?