Skip to main content
 首页 » 编程设计

python之Cherrypy:多处理

2025年05月04日9cloudgamer

我启动我的 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

如果您真的不想使用它们,您可能会减少线程池中的线程数量,但这可能会降低性能。