任务分布式运行
This commit is contained in:
1 parent
677a836569
commit
d09e0c8c17
14 files changed
+462
-53
No files matched your search
Binary file not shown.
Binary file not shown.
Binary file not shown.
+7
-3
@@ -14,7 +14,7 @@ def get_task(task_type):
|
||||
charset=config.mysql_local['charset'],) as conn:
|
||||
cursor = conn.cursor()
|
||||
|
||||
sql = f'select task_key from tasks where task_type = "{task_type}" and status = 0 order by id asc limit 1'
|
||||
sql = f'select task_key from tasks where task_type = "{task_type}" and status = 0 order by priority desc, id asc limit 1'
|
||||
# print(f'sql: {sql}')
|
||||
cursor.execute(sql)
|
||||
data = cursor.fetchone()
|
||||
@@ -36,9 +36,13 @@ def add_task(data):
|
||||
password=config.mysql_local['password'],
|
||||
db=config.mysql_local['db'],
|
||||
charset=config.mysql_local['charset'],) as conn:
|
||||
cursor = conn.cursor()
|
||||
cursor = conn.cursor()
|
||||
|
||||
sql = f'insert into tasks (task_type, task_key) values ("{data["task_type"]}", "{data["task_key"]}")'
|
||||
#判断是否是昆山教学的,是的话优先级设置为默认
|
||||
if data["psid"] == 85:
|
||||
sql = f'insert into tasks (task_type, task_key) values ("{data["task_type"]}", "{data["task_key"]}")'
|
||||
else:
|
||||
sql = f'insert into tasks (task_type, task_key, priority) values ("{data["task_type"]}", "{data["task_key"]}", 1)'
|
||||
# print(f'sql: {sql}')
|
||||
cursor.execute(sql)
|
||||
conn.commit()
|
||||
|
||||
Reference in new issue
Block a user