0

I have a background process, which does a file preparation after receiving a file on the endpoint. I have a websocket defined also:

@app.websocket_route("/ws/{uid}")
async def websocket(websocket: WebSocket):
    await websocket.accept()
   
    await websocket.send_text("Hello")
    await websocket.close()

This solution sends the Hello text when the user connects.

But I want to send the text only after the background process is finished. So my aim is to define a websocket in other function and from there send the text to a websocket. How can i do it?

0 Answers0