Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions taskvine/src/bindings/python3/ndcctools/taskvine/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,16 @@ def cancel_by_task_id(self, id):
def cancel_by_task_tag(self, tag):
return cvine.vine_cancel_by_task_tag(self._taskvine, tag)

##
# Cancel all tasks with the given tag.
# The cancelled tasks will be returned in the normal way via @ref wait with a result of VINE_RESULT_CANCELLED.
#
# @param self Reference to the current manager object.
# @param tag The tag assigned to tasks using @ref ndcctools.taskvine.task.Task.set_tag.
# @return The total number of tasks cancelled.
def cancel_all_by_tag(self, tag):
return cvine.vine_cancel_all_by_tag(self._taskvine, tag)

##
# Cancel all tasks of the given category.
# The cancelled tasks will be returned in the normal way via @ref wait with a result of VINE_RESULT_CANCELLED.
Expand Down
8 changes: 8 additions & 0 deletions taskvine/src/manager/taskvine.h
Original file line number Diff line number Diff line change
Expand Up @@ -1332,6 +1332,14 @@ The cancelled task will be returned in the normal way via @ref vine_wait with a
*/
int vine_cancel_by_task_tag(struct vine_manager *m, const char *tag);

/** Cancel all submitted tasks with the given tag and remove them from the manager.
Each cancelled task will be returned in the normal way via @ref vine_wait with a result of VINE_RESULT_CANCELLED.
@param m A manager object
@param tag The tag name assigned to tasks using @ref vine_task_set_tag.
@return The number of tasks cancelled.
*/
int vine_cancel_all_by_tag(struct vine_manager *m, const char *tag);

/** Cancel all submitted tasks and remove them from the manager.
Each cancelled task will be returned in the normal way via @ref vine_wait with a result of VINE_RESULT_CANCELLED.
@param m A manager object
Expand Down
35 changes: 35 additions & 0 deletions taskvine/src/manager/vine_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -5671,6 +5671,41 @@ int vine_cancel_by_task_tag(struct vine_manager *q, const char *task_tag)
}
}

int vine_cancel_all_by_tag(struct vine_manager *q, const char *tag)
{
int count = 0;
struct vine_task *t;
uint64_t task_id;

ITABLE_ITERATE(q->tasks, task_id, t)
{
switch (t->state) {
case VINE_TASK_RETRIEVED:
case VINE_TASK_DONE:
/* these tasks are already in a final state, so we can skip them */
continue;
default:
switch (t->type) {
case VINE_TASK_TYPE_STANDARD:
case VINE_TASK_TYPE_LIBRARY_INSTANCE:
if (task_tag_comparator(t, tag)) {
vine_cancel_by_task_id(q, task_id);
count++;
}
break;
case VINE_TASK_TYPE_RECOVERY:
case VINE_TASK_TYPE_LIBRARY_TEMPLATE:
/* recovery tasks should not be canceled (unless explicitely by task id)
* as there are temporary files that the workflow already considers done. */
continue;
break;
}
}
}

return count;
}

int vine_cancel_all(struct vine_manager *q)
{
int count = 0;
Expand Down