Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent CherryPy from automatically reloading

It boggles my mind that this hasn't already been asked on Stack Overflow, but I gave it an honest search...

I'm currently developing a simple web application using CherryPy (and routes and Mako, in case its relevant.) This is going fine except for some very helpful mechanism CherryPy possesses that automatically reloads the server process whenever I change the code; inevitably, this will futz with my IDE's debugger, crash due to half-written code, and leave behind a dud process listening on the relevant port that causes later server processes to refuse to run until I manually force-quit it from the task manager.

From looking around, it sounded like this could be disabled via the config dictionary passed to CherryPy as it initializes, e.g.

conf = {'/': {'request.dispatch': d, 'engine.autoreload.on' : False}}

cherrypy.tree.mount(root=None, config=conf)

This doesn't seem to change anything, however. Is there something I'm missing here?

like image 539
Maxander Avatar asked Feb 16 '16 21:02

Maxander


1 Answers

You have to configure the the autoreload on the global namespace because is part of the engine:

app_conf = {'/': {'request.dispatch': d}}
cherrypy.config.update({
    'global': {
       'engine.autoreload.on' : False
     }
 })
cherrypy.tree.mount(root=None, config=app_conf)

Or better yet set the production environment:

 cherrypy.config.update({
     'global': {
        'environment' : 'production'
      }
 })

Which will disable the autoreload among other things.

like image 164
cyraxjoe Avatar answered Oct 23 '22 09:10

cyraxjoe