#NEWLINE# def _prepare_build_async( self , build , project_lock ) : #NEWLINE# #INDENT# '\n        :type build: Build\n        :type project_lock: Lock\n        ' #NEWLINE# self . _logger . info ( 'Build {} is waiting for the project lock' , build . build_id ( ) ) #NEWLINE# with project_lock : #NEWLINE# #INDENT# self . _logger . info ( 'Build {} has acquired project lock' , build . build_id ( ) ) #NEWLINE# analytics . record_event ( analytics . BUILD_PREPARE_START , build_id = build . build_id ( ) , log_msg = 'Build preparation loop is handling request for build {build_id}.' ) #NEWLINE# try : #NEWLINE# #INDENT# build . prepare ( self . _subjob_calculator ) #NEWLINE# if ( not build . has_error ) : #NEWLINE# #INDENT# analytics . record_event ( analytics . BUILD_PREPARE_FINISH , build_id = build . build_id ( ) , is_success = True , log_msg = 'Build {build_id} successfully prepared.' ) #NEWLINE# if ( len ( build . all_subjobs ( ) ) == 0 ) : #NEWLINE# #INDENT# self . _logger . info ( 'Build {} has no work to perform and is exiting.' , build . build_id ( ) ) #NEWLINE# build . finish ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . _logger . info ( 'Build {} is waiting for slaves.' , build . build_id ( ) ) #NEWLINE# self . _builds_waiting_for_slaves . put ( build ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# except Exception as ex : #NEWLINE# #INDENT# build . mark_failed ( str ( self ) ) #NEWLINE# self . _logger . exception ( 'Could not handle build request for build {}.' . format ( build . build_id ( ) ) ) #NEWLINE# analytics . record_event ( analytics . BUILD_PREPARE_FINISH , build_id = build . build_id ( ) , is_success = False )