summaryrefslogtreecommitdiff
path: root/broker.py
diff options
context:
space:
mode:
authorhaoyuren <13851610112@163.com>2026-04-01 17:27:01 -0500
committerhaoyuren <13851610112@163.com>2026-04-01 17:27:01 -0500
commitf717968f55960331c2f00852f43d4a879d0b39d8 (patch)
tree1eb152faa46daa435158b358f2ce88806e158ce3 /broker.py
parent6e03525ae651616a9a2c935e58674ce31472eb19 (diff)
Fix: empty target query no longer returns all tasksHEADmain
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]}