Search code examples
pythonmultithreadingcherrypy

CherryPy: How can I start a single-threaded server?


I am running cherrypy on webfactional. I have a serious memory leak problem, and I would like to isolate its cause. How can I run cherrypy on a single thread/process?

Context: Accessing a page which allocates a large list of data increases the memory usage of the python process. The memory usage never goes down again. I suspect that the fact that cherrypy uses several threads of execution is the problem, but I have no way to disable that feature in order to isolate my problem.

The relevant part of my site.py file right now:

cherrypy.config.update({
    'environment': 'production',
    'log.screen': False,
    'log.error_file':'cperror.log',
    'server.socket_host': '127.0.0.1',
    'server.socket_port': 31266,
})

cherrypy.quickstart(Root())

I have googled a lot for a solution to my problem, and I have nothing. I have also browsed the official CherryPy documentation, to no avail.

I'm using cherrypy 3.2 and python 2.7


Solution

  • You could try this in your config file:

    [global]
    server.thread_pool = 1