refactor(process): break after first fail instead of failed_ids workaround
This commit is contained in:
parent
c3d345b6a7
commit
58b515abe9
|
|
@ -11,16 +11,10 @@ def process_once(processor, queue: Queue, writer: VaultWriter, vault_path: Path,
|
||||||
return 0
|
return 0
|
||||||
ctx = collect_vault_context(vault_path, today=today)
|
ctx = collect_vault_context(vault_path, today=today)
|
||||||
processed = 0
|
processed = 0
|
||||||
failed_ids: set[int] = set()
|
|
||||||
while True:
|
while True:
|
||||||
item = queue.claim_next()
|
item = queue.claim_next()
|
||||||
if item is None:
|
if item is None:
|
||||||
break
|
break
|
||||||
if item.update_id in failed_ids:
|
|
||||||
# Already failed this run; re-queue without incrementing and stop.
|
|
||||||
queue.enqueue(item)
|
|
||||||
(queue.working / f"{item.update_id}.json").unlink(missing_ok=True)
|
|
||||||
break
|
|
||||||
try:
|
try:
|
||||||
received_dt = datetime.fromisoformat(item.received_at)
|
received_dt = datetime.fromisoformat(item.received_at)
|
||||||
received_time = received_dt.strftime("%H:%M")
|
received_time = received_dt.strftime("%H:%M")
|
||||||
|
|
@ -44,5 +38,5 @@ def process_once(processor, queue: Queue, writer: VaultWriter, vault_path: Path,
|
||||||
processed += 1
|
processed += 1
|
||||||
except Exception:
|
except Exception:
|
||||||
queue.fail(item)
|
queue.fail(item)
|
||||||
failed_ids.add(item.update_id)
|
break # avoid re-claiming the same item in this run
|
||||||
return processed
|
return processed
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue