By default the application served with waitress uses 4 threads. The statemnt below is from waitress documentation:
threads:
The number of threads used to process application logic (integer).
Default: 4
Let’s imagine I spawn a new thread in one of my endpoints with code like this (this is only an example, not in ‘good-practices’ manner):
import threading
@app.route(/some/route, methods=["GET"])
def handle():
thread = threading.Thread(target=some_function)
thread.start()
return "a background task has started..."
What is the relationship between the 4 workers the server uses and threads created this way? If 100 requests are sent then 100 threads will be created. How it realtes to the 4 workers? Will the 100 threads be queued somehow? This is not clear to me and I don’t know how it affects the performance and machine resources – for example if I change the server workers to 2 will the execution of the 100 threads in the background be slower or no effect. I can’t get it clearly for documentation