#NEWLINE# @ utils . synchronized ( 'resource_allocator' , external = True , lock_path = '/tmp' ) #NEWLINE# def allocate( self ) : #NEWLINE# #INDENT# allocations = self . _get_allocations ( ) #NEWLINE# for i in range ( MAX_ATTEMPTS ) : #NEWLINE# #INDENT# resource = str ( self . _allocator_function ( ) ) #NEWLINE# if self . _validator ( resource , allocations ) : #NEWLINE# #INDENT# allocations . add ( resource ) #NEWLINE# self . _write_allocations ( allocations ) #NEWLINE# LOG . debug ( 'Allocated exclusive resource %s of type %s. The allocations are now: %s' , resource , self . _resource_name , allocations ) #NEWLINE# return resource #NEWLINE# #UNINDENT# #UNINDENT# raise ValueError ( ( 'Could not allocate a new resource of type %s from pool %s' % ( self . _resource_name , allocations ) ) )