summaryrefslogtreecommitdiff
path: root/broker.py
diff options
context:
space:
mode:
Diffstat (limited to 'broker.py')
-rw-r--r--broker.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/broker.py b/broker.py
index 35ba21c..2b5d5d6 100644
--- a/broker.py
+++ b/broker.py
@@ -1090,8 +1090,9 @@ def get_pending_tasks(target: str = ""):
(target,),
).fetchall()
else:
+ # 空 target 查询只返回 target 也为空的任务(防止跨 session 抢任务)
rows = db.execute(
- "SELECT id, target, type, content, created_at FROM tasks WHERE status = 'pending' ORDER BY created_at"
+ "SELECT id, target, type, content, created_at FROM tasks WHERE status = 'pending' AND target = '' ORDER BY created_at"
).fetchall()
db.close()
return {"tasks": [dict(r) for r in rows]}