cancel_job

Batch.Client.cancel_job(**kwargs)

Cancels a job in an Batch job queue. Jobs that are in the SUBMITTED , PENDING , or RUNNABLE state are canceled. Jobs that progressed to the STARTING or RUNNING state aren't canceled. However, the API operation still succeeds, even if no job is canceled. These jobs must be terminated with the TerminateJob operation.

See also: AWS API Documentation

Request Syntax

response = client.cancel_job(
    jobId='string',
    reason='string'
)
Parameters
  • jobId (string) --

    [REQUIRED]

    The Batch job ID of the job to cancel.

  • reason (string) --

    [REQUIRED]

    A message to attach to the job that explains the reason for canceling it. This message is returned by future DescribeJobs operations on the job. This message is also recorded in the Batch activity logs.

Return type

dict

Returns

Response Syntax

{}

Response Structure

  • (dict) --

Exceptions

  • Batch.Client.exceptions.ClientException
  • Batch.Client.exceptions.ServerException

Examples

This example cancels a job with the specified job ID.

response = client.cancel_job(
    jobId='1d828f65-7a4d-42e8-996d-3b900ed59dc4',
    reason='Cancelling job.',
)

print(response)

Expected Output:

{
    'ResponseMetadata': {
        '...': '...',
    },
}