def _stop_child_tasks(self, task: Task): self.provider.commit() children = self.provider.children(task.id, [Task.dag_rel]) dags = [c.dag_rel for c in children] for c, d in zip(children, dags): celery_tasks.stop(self.logger, self.session, c, d)
def dag_stop(): data = request_data() provider = DagProvider(_write_session) id = int(data['id']) dag = provider.by_id(id, joined_load=['tasks']) for t in dag.tasks: celery_tasks.stop(logger, _write_session, t, dag) return {'dag': provider.get({'id': id})['data'][0]}
def task_stop(): data = request_data() provider = TaskProvider(_write_session) task = provider.by_id(data['id'], joinedload(Task.dag_rel, innerjoin=True)) dag = task.dag_rel status = celery_tasks.stop(logger, _write_session, task, dag) child_tasks = provider.children(task.id) for t in child_tasks: celery_tasks.stop(logger, _write_session, t, dag) return {'status': to_snake(TaskStatus(status).name)}