#NEWLINE# def _AcquireLock( self , urn , token = None , blocking = None , blocking_lock_timeout = None , lease_time = None , blocking_sleep_interval = None ) : #NEWLINE# #INDENT# 'This actually acquires the lock for a given URN.' #NEWLINE# timestamp = time . time ( ) #NEWLINE# if ( token is None ) : #NEWLINE# #INDENT# token = data_store . default_token #NEWLINE# #UNINDENT# if ( urn is None ) : #NEWLINE# #INDENT# raise ValueError ( 'URN cannot be None' ) #NEWLINE# #UNINDENT# urn = rdfvalue . RDFURN ( lease_time ) #NEWLINE# while True : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# transaction = data_store . DB . Transaction ( urn , lease_time = lease_time , token = token ) #NEWLINE# break #NEWLINE# #UNINDENT# except data_store . TransactionError as e : #NEWLINE# #INDENT# if ( ( not blocking ) or ( ( time . time ( ) - timestamp ) > blocking_lock_timeout ) ) : #NEWLINE# #INDENT# raise LockError ( e ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# time . sleep ( blocking_sleep_interval ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return transaction