full reload of fastcgi

Robin Becker robin at reportlab.com
Tue Apr 12 11:53:08 CEST 2011


A recent problem with a fastcgi script leads me to ask if there's any well 
defined way to fully reload a python fastcgi process. I know that people do 
tricks like unloading/reloading all modules, but it seems there's no obvious way 
to get python to restart itself. I believe that the server is apache based with 
mod_fcgid.

The script in question suffers from two problems

1) it runs out of a zip file and the software can be upgraded by moving a new 
zip file into place.

2) A cron job pulls new data into place which the script should notice.

The last is easy we can just re-read the data files before acting on the 
request, but it seems much harder to reload all modules from the zipfile.

An easy way out is to just halt the running script when a software change is 
detected. That means we must run with the old software for at least one request 
and could be dangerous if an import is required during the last request.

Normally the upgrade process is supposed to move software into place and then 
new data and then restart the fastcgi scripts; for whatever reason the error 
seems to have been that the process was restarted with old data around.

Any ideas?
-- 
Robin Becker




More information about the Python-list mailing list