def abort_computation_tasks(cls, task_ids: List[str]) -> None: for task_id in task_ids: task_result = AbortableAsyncResult(task_id) if task_result: task_result.abort() logger.info( "Aborted celery task %s, status: %s", task_id, task_result.is_aborted(), )
def abort(self): """ Abort a task. """ if not self.is_active(): return asyncres = AbortableAsyncResult(self.task_id) if self.is_abortable(): asyncres.abort() if asyncres.is_aborted(): self.status = "ABORTED" self.save() celery.task.control.revoke(self.task_id, terminate=True, signal="SIGTERM")
def abort(self): """ Abort a task. """ if not self.is_active(): return asyncres = AbortableAsyncResult(self.task_id) if self.is_abortable(): asyncres.abort() if asyncres.is_aborted(): self.status = "ABORTED" self.save() celery.task.control.revoke(self.task_id, terminate=True, signal="SIGTERM")
def abort_func(): """ Check whether the task in question has been aborted. """ asyncres = AbortableAsyncResult(task_id) return asyncres.is_aborted()
def abort_func(): """ Check whether the task in question has been aborted. """ asyncres = AbortableAsyncResult(task_id) return asyncres.is_aborted()