Toby J Sargeant
tjs at longford.cs.monash.edu.au
Thu Nov 25 04:10:28 CET 1999
On Fri, Nov 26, 1999 at 12:16:50AM +1300, Greg Ewing wrote:
> Tim Peters wrote:
> > mutex.acquire()
> > do stuff
> > mutex.release()
> > is a syntax error in Python.
> What's *really* needed here is a way to abstract these kinds
> of constructs. In Scheme I would arrange things so that I
> could write
> (with-mutex-acquired mutex
> or in Smalltalk
> mutex do: [
Just throwing this up in the air, and seeing what comes back...
# do stuff.
It relies on Acquire.__del__() being called as soon as _a goes out
of scope, but that doesn't seem likely to change for the moment.
(Of course doing this in JPython is a recipe for disaster... or
at least extreme inefficiency)
It also has the advantage that you can exit the function in many
ways (including by exception), and the lock will be released
It also makes the whole function a critical section which is not
always what's wanted.
More information about the Python-list