def request_cancellation(liveaction, requester):
 if (liveaction.status == action_constants.LIVEACTION_STATUS_CANCELING):
  return liveaction
 if (liveaction.status not in action_constants.LIVEACTION_CANCELABLE_STATES):
  raise Exception('Unable to cancel execution because it is already in a completed state.')
 result = {'message': 'Action canceled by user.', 'user': requester}
 status = (action_constants.LIVEACTION_STATUS_CANCELING if (liveaction.status == action_constants.LIVEACTION_STATUS_RUNNING) else action_constants.LIVEACTION_STATUS_CANCELED)
 update_status(liveaction, status, result=result)
 execution = ActionExecution.get(liveaction__id=str(liveaction.id))
 return (liveaction, execution)

def request_cancellation ( liveaction , requester ) : if ( liveaction . status == action_constants . LIVEACTION_STATUS_CANCELING ) : return liveaction if ( liveaction . status not in action_constants . LIVEACTION_CANCELABLE_STATES ) : raise Exception ( 'Unable to cancel execution because it is already in a completed state.' ) result = { 'message' : 'Action canceled by user.' , 'user' : requester } status = ( action_constants . LIVEACTION_STATUS_CANCELING if ( liveaction . status == action_constants . LIVEACTION_STATUS_RUNNING ) else action_constants . LIVEACTION_STATUS_CANCELED ) update_status ( liveaction , status , result = result ) execution = ActionExecution . get ( liveaction__id = str ( liveaction . id ) ) return ( liveaction , execution )
request cancellation of an action execution .