r/Python • u/exeNOS15 • Nov 03 '25
Discussion How does fastapi handles concurrency with websocket infinite loops?
I was trying to learn websockets and it's logic is soooo hard. I thought of a simple task as a test. there will be 3 clients the 1st 2 would be in private chat room and the 3rd would be in broadcast mode. It took me 5 hrs to write this simple logic because I was facing issues for not handling the disconnect states properly. This made me wonder how does web frameworks and browsers handles concurrency with infinite loops?
14
Upvotes
2
u/exeNOS15 Nov 03 '25
So it needs to monitor each loop continuosly right even if no msgs r recieved? Is there a time frame for this before it skips to the next "loop"? Or does it just monitors the last working loop until an event happens in other loop?