Scoped Lock

Ype Kingma ykingma at accessforall.nl
Tue Jan 6 03:41:20 EST 2004


Sean R. Lynch wrote:

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

Or even:

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

Regards,
Ype




More information about the Python-list mailing list