fix: coordinate concurrent account capacity filling
This commit is contained in:
@@ -5,7 +5,7 @@ from datetime import datetime
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
from common import append_jsonl, ensure_utc, parse_datetime, read_jsonl, write_jsonl
|
||||
from common import append_jsonl, ensure_utc, parse_datetime, read_jsonl, update_jsonl
|
||||
|
||||
|
||||
WAITING_STATUSES = {"waiting", "queued"}
|
||||
@@ -32,10 +32,10 @@ def update_history_archive(
|
||||
*,
|
||||
limit: int = HISTORY_ARCHIVE_LIMIT_DEFAULT,
|
||||
) -> list[dict[str, Any]]:
|
||||
merged = merge_history_records(load_history_archive(path), tasks, limit=limit)
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
write_jsonl(path, merged)
|
||||
return merged
|
||||
return update_jsonl(
|
||||
path,
|
||||
lambda existing: merge_history_records(existing, tasks, limit=limit),
|
||||
)
|
||||
|
||||
|
||||
def merge_history_records(
|
||||
|
||||
Reference in New Issue
Block a user