I'm hoping to multithread pyramid 1.10.4 requests ... but it appears that pserve is already multithreaded. The Pyramid docs seems to say pserve is single threaded, but when I put
sleep(10)
in my view, and issue
for ii in $(seq 20); do
time wget -O tempa$ii http://localhost:6543 &> outa$ii &
done
I find that 4 of the requests complete in 10 seconds, the next 4 in 20 seconds, the next 4 in 30 seconds, etc.
Apparently somebody (pserve?) is already running 4 threads. But nowhere do I find this documented. There is no mention of threading in either development.ini or production.ini.
How can I control the number of available threads for pserve?
If pserve is the wrong way to do threading, what is the right way?
pserve is just a thin CLI runner and is not a server. You likely have the server section of your ini configured to tell pserve to use waitress. Waitress is a WSGI server that utilizes a threadpool to serve requests and you’ll want to read its docs. To change the size of the thread pool you can set threads = 10
in the server section.