#NEWLINE# def _lock( self , name , client_id , request_id ) : #NEWLINE# #INDENT# 'Handles locking\n\n        Locking time is stored to determine time out.\n        If a lock is timed out it can be acquired by a different client.\n\n        ' #NEWLINE# if ( name in self . _locks ) : #NEWLINE# #INDENT# ( other_client_id , other_request_id , lock_time ) = self . _locks [ name ] #NEWLINE# if ( other_client_id == client_id ) : #NEWLINE# #INDENT# response = ( ( self . LOCK_ERROR + self . DELIMITER ) + ( 'Re-request of lock `%s` (old request id `%s`) by `%s` (request id `%s`)' % ( name , client_id , other_request_id , request_id ) ) ) #NEWLINE# self . _logger . warning ( response ) #NEWLINE# return response #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# current_time = time . time ( ) #NEWLINE# if ( ( current_time - lock_time ) < self . _timeout ) : #NEWLINE# #INDENT# return self . WAIT #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# response = ( ( self . GO + self . DELIMITER ) + ( 'Lock `%s` by `%s` (old request id `%s) timed out' % ( name , other_client_id , other_request_id ) ) ) #NEWLINE# self . _logger . info ( response ) #NEWLINE# self . _locks [ name ] = ( client_id , request_id , time . time ( ) ) #NEWLINE# self . _timeout_locks [ ( name , other_client_id ) ] = ( request_id , lock_time ) #NEWLINE# return response #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# self . _locks [ name ] = ( client_id , request_id , time . time ( ) ) #NEWLINE# return self . GO