Batch / Client / cancel_jobs
cancel_jobs¶
- Batch.Client.cancel_jobs(**kwargs)¶
Cancels up to 50 jobs in an Batch job queue. This is a bulk version of CancelJob. Jobs that are in a
SUBMITTED,PENDING, orRUNNABLEstate are cancelled and the job status is updated toFAILED.Note
A
PENDINGjob is cancelled after all dependency jobs are completed. Therefore, it might take longer than expected to cancel a job inPENDINGstatus.When you try to cancel an array parent job in
PENDING, Batch attempts to cancel all child jobs. The array parent job is cancelled when all child jobs are completed.Jobs that progressed to the
STARTINGorRUNNINGstate aren’t cancelled. These jobs must be terminated with the TerminateJob or TerminateJobs operation.Batch reports the result for each job individually in the response. Jobs that were processed successfully are reported in the
successfullist. Jobs that encountered errors are reported in theerrorslist. The response returns an HTTP status code of200even when some jobs encountered errors, so check theerrorslist. Jobs that can’t be found are treated as successfully processed.See also: AWS API Documentation
Request Syntax
response = client.cancel_jobs( jobs=[ 'string', ], reason='string' )
- Parameters:
jobs (list) –
[REQUIRED]
An array of up to 50 Batch job IDs of the jobs to cancel.
(string) –
reason (string) –
[REQUIRED]
A message to attach to the job that explains the reason for cancelling it. This message is returned by future DescribeJobs operations on the job. It is also recorded in the Batch activity logs.
This parameter has a limit of 1024 characters.
- Return type:
dict
- Returns:
Response Syntax
{ 'successful': [ 'string', ], 'errors': [ { 'job': 'string', 'code': 'string', 'message': 'string' }, ] }
Response Structure
(dict) –
The result of a
CancelJobsrequest, including the jobs whose cancellation request was accepted and the errors for jobs that couldn’t be cancelled.successful (list) –
A list of the job IDs whose cancellation request was accepted.
(string) –
errors (list) –
A list of
CancelJobsErrorDetailitems, one for each job that couldn’t be cancelled. Each item includes the job ID along with a code and message that describe why the job wasn’t cancelled.(dict) –
An object that contains the details of a job that couldn’t be cancelled by a
CancelJobsoperation.job (string) –
The Batch job ID of the job that couldn’t be cancelled.
code (string) –
An error code that identifies the reason the job couldn’t be cancelled. Valid values are:
ValidationException– A job identifier in the request is malformed or isn’t valid.ClientException– The request failed because of a client error.ThrottlingException– The request was throttled. Retry the request.ServerException– An internal error occurred. Retry the request.AccessDenied– The caller isn’t authorized to perform the action on the specified job.
message (string) –
A message that describes the reason the job couldn’t be cancelled.
Exceptions
Batch.Client.exceptions.ClientExceptionBatch.Client.exceptions.ServerException