我启动我的 Cherrypy 代码为
python -u myApp.py
它工作正常。但是,当我执行 ps ax | grep myApp
我可以看到 21 个 python -u myApp.py
副本正在运行。这是为什么,这是为了什么?
最佳答案
CherryPy 使用多线程来处理连接。您可以通过编辑 ThreadPool 来控制它使用的数量。设置。
关于工作线程如何工作有一些细节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
如果您真的不想使用它们,您可能会减少线程池中的线程数量,但这可能会降低性能。
关于python - Cherrypy:多处理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16736352/