starlette, using a synchronous function inside a web socket
问题 I'm trying to build a web socket using starlette which receives a message, runs calculations in a synchronous function and returns a response. @app.websocket("/ws") async def websocket_endpoint(websocket: WebSocket): await websocket.accept() while True: stock = await websocket.receive_text() stock = stock.upper() data = sentiment_analysis(stock=stock) await websocket.send_json({"score": data}) the sentiment analysis is a synchronous function. so the text is received and the calculations are