def with_backing_lock(method):
 def wrapped_method(self, *args, **dargs):
  already_have_lock = (self._backing_file_lock is not None)
  if (not already_have_lock):
   self._lock_backing_file()
  try:
   return method(self, *args, **dargs)
  finally:
   if (not already_have_lock):
    self._unlock_backing_file()
 wrapped_method.__name__ = method.__name__
 wrapped_method.__doc__ = method.__doc__
 return wrapped_method

def with_backing_lock ( method ) : def wrapped_method ( self , * args , ** dargs ) : already_have_lock = ( self . _backing_file_lock is not None ) if ( not already_have_lock ) : self . _lock_backing_file ( ) try : return method ( self , * args , ** dargs ) finally : if ( not already_have_lock ) : self . _unlock_backing_file ( ) wrapped_method . __name__ = method . __name__ wrapped_method . __doc__ = method . __doc__ return wrapped_method
a decorator to perform a lock-*-unlock cycle .