durusmail: quixote-users: Patch to mod_python_handler.py needs testing
Patch to mod_python_handler.py needs testing
2001-11-13
2001-11-13
2001-11-13
2001-11-13
Patch to mod_python_handler.py needs testing
Greg Ward
2001-11-13
On 13 November 2001, Erno Kuusela said:
> seems to work at least for the demo (i still haven't gotten
> around to doing anything with quixote :/).

Great, thanks.

> btw, is there anything in quixote to automagically reload modules or
> do you just revert to cgi when you need a rapid edit-test-debug cycle?

As Neil more-or-less said, "NO MAGIC".

More importantly, it is fundamentally impossible for module reloading to
work in Python.  Believe me, I've tried several times, and each time I
run up against the same brick wall: if module b's global namespace has
an instance of class a.A, what happens when you reload module a?  The
a.A instance in b still has a bunch of bound methods that point to the
old code in the old version of a.  You lose.  So you reload b and a at
the same time: the a.A instance in b's global namespace has to be
recreated (ie. b re-imported) *after* a is re-imported.  What if there's
a cyclic dependency, ie. a's namespace has a b.B instance and b's has an
a.A method?  (Yes, you'd be nuts to set things up this way, but it's
possible.)  And what about other namespaces (eg. instances floating in
memory, closures, ...) that have a reference to b's a.A instance?  OK,
you have to scrub all those namespaces too.  It boils down to doing
sys.modules.clear(), which has its own problems.

Bottom line: might as well just restart the interpreter.

If you're using a FastCGI driver script, all you have to do is kill the
script, not the whole web server.  I use a little setuid Perl script for
that:

 $ ll ~/bin/qkill
 -rwsr-xr-x    1 nobody   mxweb          70 Mar  2  2001 /home/gward/bin/qkill*
 $ cat ~/bin/qkill
 #!/usr/local/bin/suidperl -Tw
 system "/usr/bin/killall", "vfab.fcgi"

(It doesn't have to be setuid-root, but you need to become root once to
make it setuid-nobody.)  (Umm, note that I'm assuming Linux' killall
here!)

I like Neil's editor macro idea.  Might try that myself.

        Greg


reply