I'm refactoring a project to move from Flask with flask-socketio to FastAPI with async. Two main reasons for this are to stop using threads to do what async can do, and also to keep in line with other developers at work. Client side is React with Redux.
Trying to set up a basic 'heartbeat' on the server-side that sends a 0/1 signal each second to all clients. Can't seem to figure out how to do it. I have tried using the StreamingResponse() method, but it just waits for the function given to complete then sends a whole stack of ones and zeros.
Any ideas on how to set up an 'always running' function with FastAPI that live streams simple data? I have 3 functions that need to do this.
I've also looked into flask-sse, but it requires redis, which I'd rather avoid.