Almost every Python web framework has a simple server that runs a wsgi application and automatically reloads the imported modules every time the source gets changed. I know I can look at the code and see how it's done, but that may take some time and I'm asking just out of curiosity. Does anyone have any idea how this is implemented?
+2
A:
As the author of one of the reloader mechanisms (the one in werkzeug) I can tell you that it doesn't work. What all the reloaders do is forking one time and restarting the child process if a monitor thread notices that one module changed on the file system.
Inline reload()
ing doesn't work because references to the reloaded module are not updated.
Armin Ronacher
2008-09-24 12:28:50
+1
A:
reload() does not work. "Reloading" is usually implemented by forking.
Implementing "real" reload() is extremely difficult and even the most serious attempt, twisted.python.rebuild isn't perfect.
sanxiyn
2008-09-24 12:34:47