So che cherrypy è un multithreading e ha anche un'implementazione threadpool.
Quindi volevo provare un esempio che mostra il comportamento multithread.
Ora lascia dire che ho la mia qualche funzione nella classe principale e resto tutte le cose sono configurati
Esempio di multithreading Cherrypy
def testPage(self, *args, **kwargs):
current = threading.currentThread()
print 'Starting ' , current
time.sleep(5)
print 'Ending ' ,current
return '<html>Hello World</html>'
Ora lascia dire corro la mia pagina come http://localhost:6060/root/testPage in 3-4 schede del browser.
Che risultato che ottiene è
Starting <WorkerThread(CP WSGIServer Thread-10, started 4844)>
Ending <WorkerThread(CP WSGIServer Thread-10, started 4844)>
Starting <WorkerThread(CP WSGIServer Thread-7, started 4841)>
Ending <WorkerThread(CP WSGIServer Thread-7, started 4841)>
Starting <WorkerThread(CP WSGIServer Thread-10, started 4844)>
Ending <WorkerThread(CP WSGIServer Thread-10, started 4844)>
La cosa che posso capire chiaramente che si tratta di creare nuove discussioni per l'elaborazione di ogni nuova richiesta ma non riesco a capire il motivo per cui ogni volta che ricevo
di partenza ... ending..starting ..in via
e perché non iniziare ... a partire da..inviare..in volte a volte
Perché la mia ipotesi è che time.sleep farà in modo che alcuni thread vengano sospesi e altri possano essere eseguiti in quel momento.
Dovresti provare con un software specifico, ad es. httperf: httperf --server = 127.0.0.1 --port = 6060 --num-conn = 50 --rate = 10 –