#NEWLINE# def execute_action( self , action ) : #NEWLINE# #INDENT# event = Event ( ) #NEWLINE# queue = Queue ( ) #NEWLINE# proc = Process ( target = execute_action_proc , args = ( self . execute , action , event , event ) ) #NEWLINE# proc . start ( ) #NEWLINE# heartbeat_retry = 0 #NEWLINE# while ( not event . is_set ( ) ) : #NEWLINE# #INDENT# event . wait ( config . ACTIVITY_HEARTBEAT_INTERVAL ) #NEWLINE# try : #NEWLINE# #INDENT# res = self . heartbeat ( self . task_token ) #NEWLINE# if res [ 'cancelRequested' ] : #NEWLINE# #INDENT# proc . terminate ( ) #NEWLINE# proc . join ( ) #NEWLINE# return Result ( 'cancelled' , ( - 1 ) , '' , '' , '' , ( - 1 ) ) #NEWLINE# #UNINDENT# #UNINDENT# except Exception as err : #NEWLINE# #INDENT# if ( heartbeat_retry <= config . ACTIVITY_HEARTBEAT_MAX_RETRY ) : #NEWLINE# #INDENT# heartbeat_retry += 1 #NEWLINE# continue #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# proc . terminate ( ) #NEWLINE# proc . join ( ) #NEWLINE# raise #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# result = queue . get_nowait ( ) #NEWLINE# proc . join ( ) #NEWLINE# return result