title: Python Flask: How to control the number of background threads
body: <p>I am using python flask framework for an object detection task. I have set <code>threaded=True</code>and 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?</p>