from pathlib import Path import sys import time sys.path.insert(0, str(Path(__file__).resolve().parents[1])) from server import Scanner from public_snapshot import project_snapshot, write_snapshot from attention import AttentionHistory, EXPORT scanner = Scanner() history = AttentionHistory() last_history = 0 while True: try: if time.monotonic() - last_history > 30: write_snapshot(history.collect(), EXPORT) write_snapshot(history.evidence, history.evidence_path) last_history = time.monotonic() write_snapshot(project_snapshot(scanner.snapshot(), (history.evidence or {}).get('threads'))) except Exception: print('Snapshot collection failed; retaining the previous snapshot.', flush=True) time.sleep(2)