[Twisted-Python] Reloading of the same `.rpy' file

Philippe Lafoucrière lafou at wanadoo.fr
Tue Apr 29 09:23:12 MDT 2003


I think Zope has the same behaviour. The solution is often to put a
reverse proxy before twisted.web.

On Tue, 2003-04-29 at 16:41, François Pinard wrote:
> Hi, Twisted people.
> 
> Playing with resource files, I noticed that the outer-level code within
> `.rpy' files is executed again every time the page using them is fetched by
> the browser.  If `test.py' contains:
> 
> ---------------------------------------------------------------------->
> print "Hello!"
> 
> ...
> resource = ...
> ----------------------------------------------------------------------<
> 
> than each `Alt-R' within Netscape, once `http://localhost:8080/test.rpy' has
> been loaded, will have "Hello!" added to the Twisted log file.
> 
> I would have expected the resource file to be loaded once, and reused after
> without being wholly re-initialised each time.  I tried "import remanent"
> within the resource file, and checked that "remanent" is loaded and
> intialised only once (moreover, it gets compiled!), so I'm tempted to move
> all code from `test.rpy' into `remanent.py' and reduce `test.rpy' to a mere:
> 
> ---------------------------------------------------------------------->
> import remanent
> resource = remanent.resource
> ----------------------------------------------------------------------<
> 
> which is a bit ridiculous if it has to be a standard idiom.
> 
> On the other hand, for debugging, I agree it is a bit handsome being able to
> modify `test.rpy' and trying the new version without restarting the server.
> This is a weak justification however.  Whenever the `.tap' file needs to be
> rebuilt, the server needs to be restarted anyway.  This soon warrants a
> Makefile, and adding another dependency over `test.rpy' is a simple matter.
> 
> Maybe the Twisted design is trying, here, to spare memory by not keeping
> `.rpy' code in its memory, in case these would be very numerous or contain a
> lot of code?  Or trying to protect itself against leaks from such, but how?
> I have the vague feeling that I'm missing something important in this area.
> Would some soul be kind enough to accept enlightening mine? :-)
-- 
Philippe Lafoucrière <lafou at wanadoo.fr>
InFuzzion





More information about the Twisted-Python mailing list