Scoped Lock

Sean R. Lynch seanl at chaosring.org
Tue Jan 6 02:06:05 CET 2004


How about:

def lock_call(mutex, func, *args, **kwargs):
     mutex.acquire()
     try:
         res = func(*args, **kwargs)
     finally:
         mutex.release()

     return res

def do_something(blah):
     # do stuff

m = threading.Lock
lock_call(m, do_something, "some data")



More information about the Python-list mailing list