Created
May 21, 2018 10:58
-
-
Save jaklinger/788df922b1e9cfb848ce1f8f1d31b38f to your computer and use it in GitHub Desktop.
Terminate all RUNNING AND RUNNABLE processes in boto3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import boto3 | |
client = boto3.client('batch') | |
i = 0 | |
for job in client.list_jobs(jobQueue="HighPriority", jobStatus="RUNNABLE")["jobS | |
ummaryList"]: | |
i+=1 | |
print(job["jobId"]) | |
client.terminate_job(jobId=job["jobId"], reason="Too slow") | |
time.sleep(0.2) | |
print(i) | |
i=0 | |
for job in client.list_jobs(jobQueue="HighPriority", jobStatus="RUNNING")["jobSu | |
mmaryList"]: | |
i+=1 | |
print(job["jobId"]) | |
client.terminate_job(jobId=job["jobId"], reason="Too slow") | |
time.sleep(0.2) | |
print(i) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment