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

Christopher Armstrong radix at twistedmatrix.com
Tue Apr 29 15:27:34 EDT 2003

On 2003.04.29 10:41, François Pinard wrote:
> ---------------------------------------------------------------------->
> import remanent
> resource = remanent.resource
> ----------------------------------------------------------------------<
> which is a bit ridiculous if it has to be a standard idiom.

Why is it ridiculous? The semantics for .rpy are good because they're flexible;
you can either recreate your Resource object every time, or you can cache it.

Also, mind that .rpys are meant to be as tiny as possible; they're just
supposed to be glue code between your web app code and the web server.

> 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?

Nope, just trying to remain flexible. It gives you a choice between CPU usage
(recreating your Resource every time) and memory usage (keeping your Resources
around in memory between requests).

> 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? :-)

Also, IIRC there's some sort of caching mechanism that glyph implemented for
rpys, but I don't remember how it works. IIRC, you just add "cache()" to the
top of your .rpy, or something. Unfortunately, it's not documented as it is.
Can someone comment on this? I'll add some docstrings to ResourceScript
if someone explains it.

 Twisted | Christopher Armstrong: International Man of Twistery
  Radix  |          Release Manager,  Twisted Project
---------+     http://twistedmatrix.com/users/radix.twistd/

More information about the Twisted-Python mailing list