Search code examples
pythonpyramidautoloadrestart

How to restart app when source code modified in pyramid python framework?


Is there any way to restart app when code file modified in pyramid framework?

pyramid.reload_templates

this varialbe work for template, but not for source code. I want to restart project asas code modified as nodemon npm package. Thanks


Solution

  • From the Pyramid documentation on Reloading Code (pruned for relevance):

    During development, it's often useful to run pserve using its --reload option. When --reload is passed to pserve, changes to any Python module your project uses will cause the server to restart. This typically makes development easier, as changes to Python code made within a Pyramid application is not put into effect until the server restarts.

    $VENV/bin/pserve development.ini --reload
    

    Changes to template files (such as .pt or .mak files) won't cause the server to restart. Changes to template files don't require a server restart as long as the pyramid.reload_templates setting in the development.ini file is true. Changes made to template files when this setting is true will take effect immediately without a server restart.