简体   繁体   中英

Cherrypy: multiprocessing

I launch my Cherrypy code as

python -u myApp.py

It works fine. However, when I do ps ax | grep myApp ps ax | grep myApp I can see 21 copies of python -u myApp.py running. Why is this and what is this for?

CherryPy uses multiple threads to handle connections. You can control how many it uses by editing the ThreadPool settings.

There are some details on how the worker thread works in the WSGI docs :

  • The server's listening thread runs a very tight loop, sticking incoming connections onto a Queue
  • Worker threads are kept in a pool and poll the Queue, popping off and then handling each connection
  • Each connection can consist of an arbitrary number of requests and their responses

You could probably lower the number of threads in the thread pool if you really don't want to use them, but that may lower performance.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM