Python Flask: How to control the number of background threads
When using threaded true, the number of threads will be depend on the system configuration. You need to use any production environment like gunicorn for this as flask is not supporting production environment officially. Limiting of thread count using flask is also very hard to execute.
I am using python flask framework for an object detection task. I have set threaded=Trueand multiple requests are handled well. As the detection process uses more processing power and time, I need to control the number of background threads to a certain limit. As of my knowledge, OS can manage the number of threads. But I need to limit the thread count to 4 or 5 and provide a server busy result if the request is overloaded. How can I achieve this?