分布式任务的修改,step2 和 step3 一起跑
This commit is contained in:
1 parent
5f92f7e230
commit
fe9c6e6267
3 files changed
+34
-6
No files matched your search
+14
-2
@@ -41,8 +41,16 @@ def make3d(pid):
|
||||
print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} pid: {pid} 定位点导入完成')
|
||||
|
||||
# defind_distance
|
||||
#死循环阻塞获取
|
||||
while True:
|
||||
time.sleep(3)
|
||||
#判断是否有 pid_1 的的值
|
||||
if redisLocal.sismember('model:auto_distance', pid+"_1") == False:
|
||||
continue
|
||||
#如果存在就移除掉并退出死循环
|
||||
redisLocal.lrem('model:auto_distance', 0, pid+"_0")
|
||||
break
|
||||
|
||||
time.sleep(35)
|
||||
shutil.move(os.path.join(config.workdir, pid, f'{pid}_wait.rcproj'), os.path.join(config.workdir, pid, f'{pid}.rcproj'))
|
||||
print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} pid: {pid} 定义定位点距离完成')
|
||||
#2023-10-27为了解决老版本使用step1 的 重建区域框的问题,这里加入了 -set "sfmEnableCameraPrior=True" -align -set "sfmEnableCameraPrior=False" align 使相机的对齐线统一向下后,再进行重建区域的设置
|
||||
@@ -90,10 +98,14 @@ def step2(pid,task_distributed_id=""):
|
||||
if task_distributed_id == "":
|
||||
os.system(f'python d:\\make2\\main_step3.py {pid}')
|
||||
else:
|
||||
main_service_db.update_task_distributed_detail({"task_distributed_id":task_distributed_id,"finished_at":time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())})
|
||||
#暂时 step2 step3 一起连续执行
|
||||
os.system(f'python d:\\make2\\main_step3.py {pid}')
|
||||
main_service_db.update_task_distributed({"id":task_distributed_id,"status":2,"finished_at":time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())})
|
||||
#main_service_db.update_task_distributed_detail({"task_distributed_id":task_distributed_id,"finished_at":time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())})
|
||||
return
|
||||
|
||||
def main(pid):
|
||||
redisLocal = config.redis_local
|
||||
if pid == '0':
|
||||
while True:
|
||||
# 取本地mysql队列任务,完成第二步的建模任务
|
||||
|
||||
+3
-2
@@ -209,8 +209,9 @@ def step3(pid,task_distributed_id=""):
|
||||
shutil.rmtree(os.path.join(config.workdir, pid), ignore_errors=True)
|
||||
libs_db.finish_task({"task_type": "make", "task_key": pid})
|
||||
if task_distributed_id:
|
||||
#更新子表的finished_at
|
||||
main_service_db.update_task_distributed_detail({"task_distributed_id":task_distributed_id,"finished_at":time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())})
|
||||
#因为step2 和step3 是一起跑的,所以这一步先注释掉更新子表的finished_at
|
||||
#main_service_db.update_task_distributed_detail({"task_distributed_id":task_distributed_id,"finished_at":time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())})
|
||||
|
||||
#更新主表的status 和 finished_at
|
||||
main_service_db.update_task_distributed({"id":task_distributed_id,"status":2,"finished_at":time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())})
|
||||
return
|
||||
|
||||
+17
-2
@@ -1,4 +1,4 @@
|
||||
import win32gui, win32con, time, os, sys
|
||||
import win32gui, win32con, time, os, sys,redis
|
||||
import pyautogui as ag
|
||||
import platform
|
||||
if platform.system() == 'Windows':
|
||||
@@ -100,6 +100,7 @@ def get_defineDistances(pid, left, top, right, bottom):
|
||||
time.sleep(1.5)
|
||||
ag.press('enter')
|
||||
print(f'执行距离划定{index}')
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -122,9 +123,16 @@ def defind_distance(pid, left, top, right, bottom):
|
||||
ag.hotkey('ctrl', 's') # save project
|
||||
ag.hotkey('alt', 'f4') # close project
|
||||
print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} {pid} 定义定位点距离完成')
|
||||
time.sleep(3)
|
||||
|
||||
#更新 r.lpush('model:auto_distance', pid+"_0")
|
||||
|
||||
#加入pid+"_1"的队列
|
||||
redisLocal.lpush('model:auto_distance', pid+"_1")
|
||||
#去掉pid+"_0"的队列
|
||||
redisLocal.lrem('model:auto_distance', 0, pid+"_0")
|
||||
|
||||
def main():
|
||||
redisLocal = config.redis_local
|
||||
while True:
|
||||
time.sleep(1)
|
||||
title = "wait"
|
||||
@@ -132,6 +140,13 @@ def main():
|
||||
if pid == '0':
|
||||
pass
|
||||
else:
|
||||
|
||||
#判断是否已经存在了,已经存在就不在处理了
|
||||
if redisLocal.sismember('model:auto_distance', pid+"_0") or redisLocal.sismember('model:auto_distance', pid+"_1"):
|
||||
continue
|
||||
|
||||
redisLocal.lpush('model:auto_distance', pid+"_0")
|
||||
|
||||
print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} 找到{pid}的定位点距离定义窗口,开始定位点距离定义...')
|
||||
start_time = time.time()
|
||||
defind_distance(pid, left, top, right, bottom)
|
||||
|
||||
Reference in new issue
Block a user