[Python-Dev] Re: 2.4a2, and @decorators

Heiko Wundram heikowu at ceosg.de
Wed Aug 4 18:43:11 CEST 2004


Am Mittwoch, 4. August 2004 18:35 schrieb Kevin Jacobs:
> > Note that your example, if I understand it correctly, creates a single
> > lock for all instances of class 'x', rather than for individual
> > instances of 'x'.  This is not what I'd normally expect from a
> > 'synchronized' method.
>
> Indeed it would, if implemented as described.  However, one
> could use the same syntax and implement a Synchronizer
> that implemented locks at the instance level.  Dirty tricks would
> be involved, but it is possible.  (If I _ever_ get some free time,
> I will take a stab at doing it, too.  Sounds like a good cookbook
> recipe)

It's pretty easy to implement a Synchronizer on instance level using the same 
semantics, as all method calls will receive the self parameter as the first 
parameter (except on builtin types, but you could also deal with this). I'll 
upload the patches I did to the sourceforge patch tracker once I get time to 
do so...

Anyway, I think this should be part of the threading module (as it's about 
threads, not about decorators), and should also be part of the stdlib, as 
there's lots of things that can go wrong if you try to implement it yourself, 
and this is useful enough to warrant inclusion in the stdlib...

Heiko.


More information about the Python-Dev mailing list