The problem arises with the "auto-reload" code. I've configured apache2
+ mod_wsgi in daemon mode, and only touching the wsgi file, is enough to
mod_wsgi reload the code (as Graham said in
http://code.google.com/p/modwsgi/wiki/ReloadingSourceCode)
To automatically reload without manually touching the file (developers
has restricted access to the filesystem in that server), I've created
the next solution.
Please, feel free to comment any possible problem with it.
Imagine the wsgi file is in /var/lib/wsgi/myapp.wsgi.
I've added the next code to the __init__.py
WSGIFILE = '/var/lib/wsgi/myapp.wsgi'
def touch_and_reload(event):
with file(WSGIFILE, 'a'):
os.utime(WSGIFILE, None)
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application. """
...
if settings['pyramid.reload_templates'] == 'true':
config.add_subscriber('myapp.touch_and_reload',
'pyramid.events.NewRequest')
config.scan()
...
This way the file is touched in every request, and every new python code
added, is automatically reloaded (Only for developing stages, of course :)
Greetings