RELEASED Python 2.4, alpha 2

Christopher T King squirrel at WPI.EDU
Thu Aug 5 13:52:05 EDT 2004


On Thu, 5 Aug 2004, Christopher T King wrote:

> On Thu, 5 Aug 2004, Heiko Wundram wrote:
> 
> > Now tell me that using decorators to do synchronization isn't a lot easier to 
> > read than the first (old) example is, and also less error-prone (resp. 
> > acquiring/releasing locks properly and without deadlocks).
> 
> I'll admit synchronization is a strong use case (since I don't believe it 
> justifies language support, like it has in Java), but I just think there's 
> a better way to go about things that no-one's thought of yet.

Replying to myself here...

Why would one necessarily use method synchronization in Python, since any
well-designed Python function should be re-entrant (though I'm sure there
is the rare exception)?  It would seem that data access synchronization is
all that's needed for most threaded applications, and the only way to 
apply that is through the try/finally construct, since Python does not 
(yet?) provide built-in data synchronization.

Of course, sometimes all a function does is access a synchronized piece of
data (especially in the case of accessor functions used to simulate
synchronized data access), in which case method synchronization is
equivalent to the synchronization of that piece of data, and decorators
can be applied to the method as a whole.




More information about the Python-list mailing list