[Twisted-Python] WSGI Question
phil at bubblehouse.org
Wed Jan 20 15:43:11 EST 2010
On Jan 20, 2010, at 3:23 PM, Alex Clemesha wrote:
> I really want to getting reloading going. I already have a ticket here:
> that describes this issue, with a couple of notes. Please add to this
> ticket / post any patches if you getting anywhere with this.
I don't think it gets much better than Django's approach. Basically, the server code loads everything it needs to bootstrap, and then forks.
All the request handling and subsequent code execution takes place in the child process, so that when modules are loaded, they are only loaded into the child's memory space.
Then, before any request is processed, the child checks the originating files for all of the modules in sys.modules, and sees if any of them have a new modification date.
If so, the child process is killed, which is detected by the parent, which respawns the child. The respawned child has the state of the parent process (which hasn't loaded any external modules), so modules get freshly imported.
t.p.rebuild() is a big improvement over the stock reload() function, but in addition to requiring modules to be marked with the "ALLOW_TWISTED_REBUILD" flag, it suffers from the same issue that it's only able to reload modules that are in the current scope.
More information about the Twisted-Python