[Twisted-Python] Re: Deferred style question.

Anthony Baxter anthony at interlink.com.au
Sat Jan 8 07:21:07 EST 2005


On Saturday 08 January 2005 07:55, David Bolen wrote:
> Bob Ippolito <bob at redivi.com> writes:
>
> (...)
>
> > Well, I think this or something like it should go in.  I've been using
> > this idiom for years, actually.
>
> I'd agree - we have similar scenarios and this is the same approach
> we've been taking.

Once I'd written it down, I went back and found I'd done something 
similar, but not quite as general, on any number of previous occasions.

I think it really should go in - so, the obvious question is: what else 
needs to be done to put it in? The current version in shtoom svn 
supports a couple of different options - whether to allow unhashable
arguments (in which case no caching is done), whether to cache only
operations in progress, or cache all operations. It also supports a 
cache clearing method, and works nicely as either a 2.4-style 
decorator, or an older style decorator. There's unittests (although it
still needs tests for the .errback handling, will be added shortly).

Current code is at 
http://divmod.org/cvs/branches/improved-stun/shtoom/defcache.py?root=Shtoom&view=markup

Anthony
-- 
Anthony Baxter     <anthony at interlink.com.au>
It's never too late to have a happy childhood.




More information about the Twisted-Python mailing list