Fix audit findings in queue fairness and official account lifecycle
This commit is contained in:
@@ -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"]
|
||||
):
|
||||
|
||||
Reference in New Issue
Block a user