Python stop execution

14 Python code examples are found related to " stop execution". You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.
Example 1
Source File: execution.py    From mars with Apache License 2.0 6 votes vote down vote up
def stop_execution(self, session_id, graph_key):
        """
        Mark graph for stopping
        :param session_id: session id
        :param graph_key: graph key
        """
        logger.debug('Receive stop for graph %s', graph_key)
        try:
            graph_record = self._graph_records[(session_id, graph_key)]
        except KeyError:
            return

        graph_record.stop_requested = True
        if graph_record.state == ExecutionState.ALLOCATING:
            if graph_record.mem_request:
                self._mem_quota_ref.cancel_requests(
                    tuple(graph_record.mem_request.keys()), build_exc_info(ExecutionInterrupted), _tell=True)
        elif graph_record.state == ExecutionState.CALCULATING:
            if self._daemon_ref is not None and graph_record.calc_actor_uid is not None:
                self._daemon_ref.kill_actor_process(self.ctx.actor_ref(graph_record.calc_actor_uid), _tell=True) 
Example 2
Source File: __init__.py    From ACE with Apache License 2.0 6 votes vote down vote up
def stop_threaded_execution(self):
        if not self.is_threaded:
            return

        logging.info("stopping threaded execution for {}".format(self))

        self.threaded_execution_stop_event.set()
        start = datetime.datetime.now()
        while True:
            self.threaded_execution_thread.join(5)
            if not self.threaded_execution_thread.is_alive():
                break

            logging.error("thread {} is not stopping".format(self.threaded_execution_thread))

            # have we been waiting for a really long time?
            if (datetime.datetime.now() - start).total_seconds() >= saq.EXECUTION_THREAD_LONG_TIMEOUT:
                logging.critical("execution thread {} is failing to stop - process dying".format(
                                  self.threaded_execution_thread))
                # suicide
                os._exit(1)

        logging.debug("threaded execution module {} has stopped ({})".format(self, self.threaded_execution_thread)) 
Example 3
Source File: athena.py    From aws-data-wrangler with Apache License 2.0 6 votes vote down vote up
def stop_query_execution(query_execution_id: str, boto3_session: Optional[boto3.Session] = None) -> None:
    """Stop a query execution.

    Requires you to have access to the workgroup in which the query ran.

    Parameters
    ----------
    query_execution_id : str
        Athena query execution ID.
    boto3_session : boto3.Session(), optional
        Boto3 Session. The default boto3 session will be used if boto3_session receive None.

    Returns
    -------
    None
        None.

    Examples
    --------
    >>> import awswrangler as wr
    >>> wr.athena.stop_query_execution(query_execution_id='query-execution-id')

    """
    client_athena: boto3.client = _utils.client(service_name="athena", session=boto3_session)
    client_athena.stop_query_execution(QueryExecutionId=query_execution_id) 
Example 4
Source File: execution.py    From fastlane with MIT License 5 votes vote down vote up
def perform_stop_job_execution(job, execution, logger, stop_schedule=True):
    if "retries" in job.metadata:
        logger.info("Cleared any further job retries.")
        job.metadata["retry_count"] = job.metadata["retries"] + 1
        job.save()

    if stop_schedule and "enqueued_id" in job.metadata:
        logger.info("Removed job from scheduling.")
        current_app.jobs_queue.deschedule(job.metadata["enqueued_id"])
        job.scheduled = False

    if execution is not None:
        if execution.status == JobExecution.Status.running:
            logger.debug("Stopping current execution...")
            executor = current_app.executor
            executor.stop_job(job.task, job, execution)
            logger.debug("Current execution stopped.")

            if execution.error is None:
                execution.error = ""
            execution.error += "\nUser stopped job execution manually."
            execution.status = JobExecution.Status.failed

    job.save()

    logger.debug("Job stopped.")

    return True, None 
Example 5
Source File: execution.py    From fastlane with MIT License 5 votes vote down vote up
def stop_job_execution(task_id, job_id, execution_id):
    logger = g.logger.bind(
        operation="stop_job_execution",
        task_id=task_id,
        job_id=job_id,
        execution_id=execution_id,
    )

    logger.debug("Getting job...")
    job = Job.get_by_id(task_id=task_id, job_id=job_id)

    if job is None:
        msg = f"Task ({task_id}) or Job ({job_id}) not found."

        return return_error(msg, "stop_job_execution", status=404, logger=logger)

    execution = job.get_execution_by_id(execution_id)

    if execution is None:
        msg = f"Job Execution ({execution_id}) not found in Job ({job_id})."

        return return_error(msg, "stop_job_execution", status=404, logger=logger)

    _, response = perform_stop_job_execution(
        job, execution=execution, logger=logger, stop_schedule=False
    )

    if response is not None:
        return response

    return format_execution_details(job.task, job, execution, shallow=True) 
Example 6
Source File: coordinator.py    From video-long-term-feature-banks with Apache License 2.0 5 votes vote down vote up
def stop_on_execution(self):
        try:
            yield
        except Exception:
            if not self.should_stop():
                traceback.print_exc()
                self.request_stop()
                os._exit(0) 
Example 7
Source File: transformer.py    From python-weka-wrapper3 with GNU General Public License v3.0 5 votes vote down vote up
def stop_execution(self):
        """
        Triggers the stopping of the object.
        """
        super(LoadDataset, self).stop_execution()
        self._loader = None
        self._iterator = None 
Example 8
Source File: athena.py    From pyboto3 with MIT License 5 votes vote down vote up
def stop_query_execution(QueryExecutionId=None):
    """
    Stops a query execution. Requires you to have access to the workgroup in which the query ran.
    For code samples using the AWS SDK for Java, see Examples and Code Samples in the Amazon Athena User Guide .
    See also: AWS API Documentation
    
    Exceptions
    
    :example: response = client.stop_query_execution(
        QueryExecutionId='string'
    )
    
    
    :type QueryExecutionId: string
    :param QueryExecutionId: [REQUIRED]\nThe unique ID of the query execution to stop.\nThis field is autopopulated if not provided.\n

    :rtype: dict
ReturnsResponse Syntax{}


Response Structure

(dict) --



Exceptions

Athena.Client.exceptions.InternalServerException
Athena.Client.exceptions.InvalidRequestException


    :return: {}
    
    
    :returns: 
    Athena.Client.exceptions.InternalServerException
    Athena.Client.exceptions.InvalidRequestException
    
    """
    pass 
Example 9
Source File: athena_cli.py    From athena-cli with Apache License 2.0 5 votes vote down vote up
def stop_query_execution(self, execution_id):
        try:
            return self.athena.stop_query_execution(
                QueryExecutionId=execution_id
            )
        except ClientError as e:
            sys.exit(e) 
Example 10
Source File: client.py    From boto3_type_annotations with MIT License 5 votes vote down vote up
def stop_query_execution(self, QueryExecutionId: str) -> Dict:
        """
        Stops a query execution. Requires you to have access to the workgroup in which the query ran.
        For code samples using the AWS SDK for Java, see `Examples and Code Samples <http://docs.aws.amazon.com/athena/latest/ug/code-samples.html>`__ in the *Amazon Athena User Guide* .
        See also: `AWS API Documentation <https://docs.aws.amazon.com/goto/WebAPI/athena-2017-05-18/StopQueryExecution>`_
        
        **Request Syntax**
        ::
          response = client.stop_query_execution(
              QueryExecutionId='string'
          )
        
        **Response Syntax**
        ::
            {}
        
        **Response Structure**
          - *(dict) --* 
        :type QueryExecutionId: string
        :param QueryExecutionId: **[REQUIRED]**
          The unique ID of the query execution to stop.
          This field is autopopulated if not provided.
        :rtype: dict
        :returns:
        """
        pass 
Example 11
Source File: client.py    From boto3_type_annotations with MIT License 5 votes vote down vote up
def stop_execution(self, executionArn: str, error: str = None, cause: str = None) -> Dict:
        """
        Stops an execution.
        See also: `AWS API Documentation <https://docs.aws.amazon.com/goto/WebAPI/states-2016-11-23/StopExecution>`_
        
        **Request Syntax**
        ::
          response = client.stop_execution(
              executionArn='string',
              error='string',
              cause='string'
          )
        
        **Response Syntax**
        ::
            {
                'stopDate': datetime(2015, 1, 1)
            }
        
        **Response Structure**
          - *(dict) --* 
            - **stopDate** *(datetime) --* 
              The date the execution is stopped.
        :type executionArn: string
        :param executionArn: **[REQUIRED]**
          The Amazon Resource Name (ARN) of the execution to stop.
        :type error: string
        :param error:
          The error code of the failure.
        :type cause: string
        :param cause:
          A more detailed explanation of the cause of the failure.
        :rtype: dict
        :returns:
        """
        pass 
Example 12
Source File: klfdb.py    From ActionScript3 with GNU General Public License v3.0 5 votes vote down vote up
def stop_execution(self, eip, break_on_next):

		function = next((x for x in self.traced if x["ea"] == eip), None)
		
		if (function is not None):

			function["hit"] += 1
		
			print("[*] Executing %s" % function["name"])
		
			if (function["hit"] == self.max_hit_count):

				ret = ask_yn(-1, 'Function "%s" was hit %d times. Would you like to exclude it from trace list?' % (function["name"], self.max_hit_count))

				if (ret == 1):

					if (function["name"]):
						self.ignore_appended.append(function["name"])

					idc.del_bpt(function["ea"])

			# Check if we want to debug it

			if (break_on_next):
				return True

			if (function["name"] is not None):

				if (function["name"] in self.debug_if_equals):
					return True
	
				if (any(x for x in self.debug_if_contains if x in function["name"])):
					return True

			return False
		
		return True 
Example 13
Source File: sfn.py    From pyboto3 with MIT License 4 votes vote down vote up
def stop_execution(executionArn=None, error=None, cause=None):
    """
    Stops an execution.
    This API action is not supported by EXPRESS state machines.
    See also: AWS API Documentation
    
    Exceptions
    
    :example: response = client.stop_execution(
        executionArn='string',
        error='string',
        cause='string'
    )
    
    
    :type executionArn: string
    :param executionArn: [REQUIRED]\nThe Amazon Resource Name (ARN) of the execution to stop.\n

    :type error: string
    :param error: The error code of the failure.

    :type cause: string
    :param cause: A more detailed explanation of the cause of the failure.

    :rtype: dict

ReturnsResponse Syntax
{
    'stopDate': datetime(2015, 1, 1)
}


Response Structure

(dict) --

stopDate (datetime) --
The date the execution is stopped.







Exceptions

SFN.Client.exceptions.ExecutionDoesNotExist
SFN.Client.exceptions.InvalidArn


    :return: {
        'stopDate': datetime(2015, 1, 1)
    }
    
    
    :returns: 
    SFN.Client.exceptions.ExecutionDoesNotExist
    SFN.Client.exceptions.InvalidArn
    
    """
    pass