INNER CODE UNIT · Python
save_active
yashab-cyber/HackGpt · workbench/server.py:53
def save_active(self, report):
if (
not isinstance(report, dict)
or report.get("status") != "running"
or not isinstance(report.get("id"), str)
):
raise ValueError("Only running report snapshots may be checkpointed")
raw = json.dumps(report)
if len(raw.encode()) > 2_000_000:
raise ValueError("Running report snapshot is too large")
with closing(sqlite3.connect(self.path, timeout=5)) as connection:
connection.execute(
"INSERT OR REPLACE INTO active_runs VALUES (?, ?, ?)",
(report["id"], report["started_at"], raw),
)
connection.commit()
def finalize(self, report):