Skip to content

Instantly share code, notes, and snippets.

@gregarndt
Last active August 10, 2016 20:55
Show Gist options
  • Save gregarndt/6b27182c2879bcc77082c811dd86041a to your computer and use it in GitHub Desktop.
Save gregarndt/6b27182c2879bcc77082c811dd86041a to your computer and use it in GitHub Desktop.
import taskcluster from 'taskcluster-client';
let taskGroupId = 'cfMDvTzETHagYx-uSPCOxQ';
async () => {
let queue = new taskcluster.Queue();
let continuationToken;
let cancellations = [];
do {
let result = await queue.listTaskGroup(taskGroupId, continuationToken? {continuationToken} : {});
continuationToken = result.continuationToken;
for (let task of result.tasks) {
if (["pending", "running"].includes(task.status.state)) {
console.log(`cancelling ${task.status.taskId}`);
cancellations.push(queue.cancelTask(task.status.taskId));
}
}
} while(continuationToken)
console.log(`waiting for ${cancellations.length} to finish`);
await Promise.all(cancellations);
}().catch(e => {console.log(e)});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment