Is this really so?
It depends. Code reloading is very specific to a hosting solution. Most servers provide some way to automatically reload the WSGI script itself, but there is no standardization; indeed, the question of how the WSGI application object is connected to the web server generally differs in different hosting environments. (You can only make one script file that works as a deployment glue for CGI, mod_wsgi, passenger, and ISAPI_WSGI, but it is not completely trivial.)
What Python really fights, however, is a module reload. This is problematic for WSGI applications, because any non-trivial webapp will encapsulate its functionality in modules and packages, and not in simple stand-alone scripts. It turns out that reloading modules are quite complicated, because if you reload() them one by one, they can easily get bad links to old versions. Ideally, the whole Python interpreter should reload the way forward when some file is updated, but in practice it seems that some C extensions do not seem to like, so this is usually not done.
There are workarounds for reloading a group of modules at the same time, which can reliably update the application when one of its modules is affected. I use a deployment module that does this (which I donβt have to publish, but can get you a copy if you're interested), and it works great for my own web applications. But you need a little discipline to make sure that you do not accidentally leave references to objects of old modules in other modules that you do not reload; If you are talking about a multitude of sites written by third parties whose code may be leaky, this may not be ideal.
In this case, you can see something like running mod_wsgi in daemon mode with a group of applications for each side and a process-level reboot and touch the WSGI script when you update any of the modules.
You are right to complain; this (and many other WSGI deployment issues) can be done with some standardization help.
bobince
source share