Fix audit findings in queue fairness and official account lifecycle

This commit is contained in:
Pigway
2026-10-05 00:21:17 +08:00
parent b76af5ada3
commit a180dbc076
12 changed files with 285 additions and 37 deletions
+15 -3
View File
@@ -217,11 +217,23 @@ class DisplayService:
(device_id, now_iso()),
)
def queued_operations(self):
cursor_time, cursor_id = "", ""
while True:
rows = self.db.all(
"SELECT * FROM operations WHERE status='QUEUED' AND "
"(created_at>? OR (created_at=? AND id>?)) "
"ORDER BY created_at,id LIMIT 50",
(cursor_time, cursor_time, cursor_id),
)
if not rows:
return
yield from rows
cursor_time, cursor_id = rows[-1]["created_at"], rows[-1]["id"]
def process_one(self):
with self.lock:
for op in self.db.all(
"SELECT * FROM operations WHERE status='QUEUED' ORDER BY created_at LIMIT 50"
):
for op in self.queued_operations():
if op["action"] not in ("render", "local-upload") and self.blocked(
op["device_id"]
):