Scoped Lock

Marco Bubke marco at
Sun Jan 4 20:19:02 CET 2004


There is the Lock object in the threading module.
But there is no medode there I could aquire a scoped
lock like:

mutex = threading.Lock()
my_lock = mutex.scoped_acquire() # maybe scoped_lock()
#now this stuff is locked

del mylock

#the lock is released.

def do_domething:
  my_lock = mutex.scoped_acquire()
  #now this stuff is locked  
  #the lock is released after its out of scope

I have written this my own but I'm not sure there is a drawback
because its looks so convinent. So I wonder why its not in 
the module?



More information about the Python-list mailing list