任务分布式运行

This commit is contained in:
dongchangxi committed 2023-10-09 15:07:46 +08:00
1 parent 677a836569
commit d09e0c8c17
14 files changed
+462 -53

No files matched your search

+46
View File
@@ -0,0 +1,46 @@
import sys,socket,time
sys.path.append('logic')
import logic_main_service
import logging
import main_step1,main_step2,main_step3
if __name__ == '__main__':
#循环值守
while True:
data = logic_main_service.get_task_distributed()
#判断data数据类型
if isinstance(data, str):
print("没有可执行的任务 sleep 3s")
time.sleep(3)
continue
else:
if data["run_step"] == "step1":
# 本地测试分布运行的用
# time.sleep(5)
# print("更新step1的结束时间",time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))
# logic_main_service.update_task_distributed_detail({"task_distributed_id":data["task_distributed_id"],"step":"step1","finished_at":time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())})
#生产线上用
main_step1.step1(data["task_key"], experience, makeloop=False,data['task_distributed_id'])
elif data["run_step"] == "step2":
# 本地测试分布运行的用
# time.sleep(15)
# print("更新step2的结束时间",time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))
# logic_main_service.update_task_distributed_detail({"task_distributed_id":data["task_distributed_id"],"step":"step2","finished_at":time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())})
#生产线上用
main_step2.step2(data["task_key"], data['task_distributed_id'])
elif data["run_step"] == "step3":
# 本地测试分布运行的用
# time.sleep(8)
# #更新子表的finished_at
# print("更新step3的结束时间",time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))
# logic_main_service.update_task_distributed_detail({"task_distributed_id":data["task_distributed_id"],"step":"step3","finished_at":time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())})
#更新主表的status 和 finished_at
#logic_main_service.update_task_distributed({"id":data["task_distributed_id"],"status":2,"finished_at":time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())})
#生产线上用
main_step3.step3(data["task_key"], data['task_distributed_id'])