#NEWLINE# def acquire( self ) : #NEWLINE# #INDENT# 'Acquires lock and returns `True`\n\n        Blocks until lock is available.\n\n        ' #NEWLINE# self . start ( test_connection = False ) #NEWLINE# while True : #NEWLINE# #INDENT# ( str_response , retries ) = self . _req_rep_retry ( LockerServer . LOCK ) #NEWLINE# response = str_response . split ( LockerServer . DELIMITER ) #NEWLINE# if ( response [ 0 ] == LockerServer . GO ) : #NEWLINE# #INDENT# return True #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( response [ 0 ] == LockerServer . LOCK_ERROR ) and ( retries > 0 ) ) : #NEWLINE# #INDENT# self . _logger . error ( ( str_response + '; Probably due to retry' ) ) #NEWLINE# return True #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( response [ 0 ] == LockerServer . WAIT ) : #NEWLINE# #INDENT# time . sleep ( self . SLEEP ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise RuntimeError ( ( 'Response `%s` not understood' % response ) )