network error

This commit is contained in:
2023-02-19 04:11:23 +08:00
parent 3816363a7e
commit 522e27080c

View File

@@ -223,13 +223,14 @@ def update_task_status(task: dict, status: str, progress: int, data: list = []):
requests.put(f"http://localhost:3000/api/drawing/{task['id']}", json=task) requests.put(f"http://localhost:3000/api/drawing/{task['id']}", json=task)
# 从局域网中获取一组任务(如果列表为空等待2s后重新获取) # 从局域网中获取一组任务(如果列表为空等待2s后重新获取)
def get_tasks(): def get_tasks(tasks:list=[]):
tasks = requests.get("http://localhost:3000/api/drawing?status=waiting").json() while len(tasks) == 0:
if len(tasks) == 0: try:
while len(tasks) == 0:
print('no task, wait 2s...')
time.sleep(2)
tasks = requests.get("http://localhost:3000/api/drawing?status=waiting").json() tasks = requests.get("http://localhost:3000/api/drawing?status=waiting").json()
if len(tasks) == 0: time.sleep(2)
except:
print("get tasks error")
time.sleep(2)
return tasks return tasks
def main_dev(opt): def main_dev(opt):