reloading updated modules in long running server?

exarkun at divmod.com exarkun at divmod.com
Fri Oct 15 13:43:32 EDT 2004


On Fri, 15 Oct 2004 10:36:40 -0700, aurora <aurora00 at gmail.com> wrote:
>I am looking for a way for reloading updated modules in a long running  
> server. I'm not too concerned about cascaded reload or objects already  
> created. Just need to reload module xxx if the corresponding xxx.py is  
> updated.
> 
> I found something useful in module.__file__. Would it work if I use it to  
> generate filenames xxx.py xxx.pyc and then compare their mtime? I'm not  
> too sure about the mechanism of generation of .pyc file. Would it be too  
> system specific to reply on?

  Is it really important that they be reloaded automatically as soon as they change?  What if several modules are being updated in concert, and the change is noticed before all of the files have been updated?  Won't the source be in an inconsistent state and probably take down, or at least effect negatively, the server?

  I would put a big fat (possibly figurative) button on the application somewhere and press it when I wanted the source updated.

  Jp



More information about the Python-list mailing list