分布式任务的修改,step2 和 step3 一起跑

This commit is contained in:
dongchangxi committed 2023-10-29 17:57:21 +08:00
1 parent 5f92f7e230
commit fe9c6e6267
3 files changed
+34 -6

No files matched your search

+17 -2
View File
@@ -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)