Something I was just thinking about:
Let's say I write a view code for my Django site, and I make a mistake and create an infinite loop.
Whenever someone tries to access a view, the worker assigned to the request (whether it be a working Gevent or a Python thread) will remain in the loop indefinitely.
If I understood correctly, the server would send a timeout error to the client in 30 seconds. But what will happen to the Python worker? Will it continue to work endlessly? That sounds dangerous!
Imagine that I have a server on which I have allocated 10 workers. I let it work, and at some point the client tries to access the view using an infinite loop. An employee will be assigned to him and will be effectively dead until the next server restart. It is dangerous that at first I would not notice this, because the site would be imperceptibly slower, having 9 workers instead of 10. But then this can happen again and again over a long period of time, maybe months. The site will become slower, until, in the end, it will be very slow with one employee.
Restarting the server will solve the problem, but I would not want my site functionality to depend on a server reboot.
Is this a real problem? Is there any way to avoid this?
Update:. I am also very grateful that I found a thread / worker stop path that was stuck in an infinite loop, so I could send it by email so that I know the problems. (I do not know how to do this because there are no exceptions.)
Refresh for people saying that “Avoid writing code with infinite loops”: in case it wasn’t obvious, I don’t spend my free time deliberately putting endless loops in my code. When this happens, they are bugs, and bugs can be minimized, but never completely eliminated. I want to know that even when I'm wrong, there will be a security network that will notify me and allow me to solve the problem.
Ram rachum
source share