Medusa: Reloading Python Source

Ian Bicking ianb at colorstudy.com
Sun May 25 15:13:37 EDT 2003


On Sun, 2003-05-25 at 01:07, Thomas Guettler wrote:
> Hi!
> 
> If you are developing applications with medusa, you need to restart it
> every time you change your source code. It would be nice if the server
> would detect changes automatically.
> 
> I tried to apply the "magic" that is done by zope's refresh, but
> failed.
> 
> Can twisted do this?

We have a technique we've been using in Webware a while, where it polls
all the loaded files (as found in sys.modules), and sees if they've
changed.  If any have, the monitor thread starts a shutdown, with exit
code 3.  The shell script that starts the AppServer does a restart if it
gets that exit code.

It works pretty well, and performs well enough for development.  The
problem with reloading that we'd probably find is stale objects that use
old class definitions.  Reloading the modules, and redefining the
classes, doesn't deal with persistent objects.  Making it do so seems
really hard (though I imagine ZODB is a help there, because the class
definitions are probably always reloaded when an object is fetched from
the database).

  Ian







More information about the Python-list mailing list