mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-25 10:58:52 -06:00
refactor: host lock and measurement records go low
This commit is contained in:
1 parent
a40c75e689
commit
fdb7b6f912
21 files changed
+160
-118
No files matched your search
@@ -0,0 +1,19 @@
|
||||
"""State files of unattended jobs: UTC timestamps and atomic JSON writes."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import datetime as dt
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def now_iso() -> str:
|
||||
return dt.datetime.now(dt.timezone.utc).replace(microsecond=0).isoformat()
|
||||
|
||||
|
||||
def save_state(path: Path, state: dict) -> None:
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
scratch = path.with_suffix(".tmp")
|
||||
scratch.write_text(json.dumps(state, indent=2, sort_keys=True) + "\n", encoding="utf-8")
|
||||
os.replace(scratch, path)
|
||||
Reference in new issue
Block a user