Atomically write progress JSON to a file (cross-process safe).
(session_id: str, data: dict)
| 300 | _write_progress_file(session_id, {"done": True}) |
| 301 | |
| 302 | def _write_progress_file(session_id: str, data: dict): |
| 303 | """Atomically write progress JSON to a file (cross-process safe).""" |
| 304 | path = _progress_file(session_id) |
| 305 | tmp_path = path + ".tmp" |
| 306 | try: |
| 307 | with open(tmp_path, 'w') as f: |
| 308 | json.dump(data, f) |
| 309 | os.replace(tmp_path, path) # atomic on POSIX |
| 310 | except Exception: |
| 311 | pass |
| 312 | |
| 313 | # Monkey-patch tqdm to intercept progress |
| 314 | import tqdm as _tqdm_module |
no test coverage detected