MCPcopy Create free account
hub / github.com/C3ting/ARL / post

Method post

app/routes/github_task.py:117–144  ·  view source on GitHub ↗

Github 任务停止

(self)

Source from the content-addressed store, hash-verified

115 @auth
116 @ns.expect(stop_github_task_fields)
117 def post(self):
118 """
119 Github 任务停止
120 """
121 done_status = [TaskStatus.DONE, TaskStatus.STOP, TaskStatus.ERROR]
122 args = self.parse_args(stop_github_task_fields)
123 task_id_list = args.pop('_id')
124
125 for task_id in task_id_list:
126 task_data = utils.conn_db('github_task').find_one({'_id': ObjectId(task_id)})
127 if not task_data:
128 return utils.build_ret(ErrorMsg.NotFoundTask, {"_id": task_id})
129
130 if task_data["status"] in done_status:
131 return utils.build_ret(ErrorMsg.TaskIsDone, {"_id": task_id})
132
133 celery_id = task_data.get("celery_id")
134 if not celery_id:
135 return utils.build_ret(ErrorMsg.CeleryIdNotFound, {"_id": task_id})
136
137 control = celerytask.celery.control
138
139 control.revoke(celery_id, signal='SIGTERM', terminate=True)
140
141 update_data = {"$set": {"status": TaskStatus.STOP, "end_time": utils.curr_date()}}
142 utils.conn_db('github_task').update_one({'_id': ObjectId(task_id)}, update_data)
143
144 return utils.build_ret(ErrorMsg.Success, {"_id": task_id_list})

Callers

nothing calls this directly

Calls 2

parse_argsMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected