homelab: Arcane und Docker (eigene Version oeffentlich, Images mit Schluessel, Updates zuerst als Probelauf); Datei-Sperren gegen Windows-Wettlauf
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
5e9227c4a3
commit
209549f0f3
@@ -84,12 +84,14 @@ def zuletzt() -> float | None:
|
||||
# --- Bericht ------------------------------------------------------------------------------
|
||||
|
||||
def bericht_speichern(daten: dict) -> None:
|
||||
_json_schreiben(_dir() / "pve-bericht.json", {"empfangen": time.time(), "bericht": daten})
|
||||
with _lock:
|
||||
_json_schreiben(_dir() / "pve-bericht.json", {"empfangen": time.time(), "bericht": daten})
|
||||
|
||||
|
||||
def bericht() -> dict | None:
|
||||
"""{"empfangen": Unix-Sekunden, "bericht": {...}} oder None, solange nie einer kam."""
|
||||
daten = _json_lesen(_dir() / "pve-bericht.json", None)
|
||||
with _lock:
|
||||
daten = _json_lesen(_dir() / "pve-bericht.json", None)
|
||||
return daten if isinstance(daten, dict) and isinstance(daten.get("bericht"), dict) else None
|
||||
|
||||
|
||||
@@ -152,7 +154,10 @@ def ergebnis(auftrag_id: str, code: int, text: str) -> bool:
|
||||
|
||||
|
||||
def auftrag(auftrag_id: str) -> dict | None:
|
||||
return next((a for a in _alle() if a["id"] == auftrag_id), None)
|
||||
# Lesen unter derselben Sperre wie das Schreiben: Unter Windows scheitert das atomare Ersetzen,
|
||||
# solange ein anderer Thread die Datei offen hat.
|
||||
with _lock:
|
||||
return next((a for a in _alle() if a["id"] == auftrag_id), None)
|
||||
|
||||
|
||||
def warten(auftrag_id: str, zeitlimit_s: float, takt_s: float = 2.0) -> dict | None:
|
||||
@@ -167,4 +172,5 @@ def warten(auftrag_id: str, zeitlimit_s: float, takt_s: float = 2.0) -> dict | N
|
||||
|
||||
|
||||
def liste() -> list[dict]:
|
||||
return list(reversed(_alle()))
|
||||
with _lock:
|
||||
return list(reversed(_alle()))
|
||||
|
||||
Reference in New Issue
Block a user