You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Prevent lost settings updates and partial configuration writes #14
my-plugin/routes.py performs an unlocked read–merge–write in asyncio.to_thread and writes directly to the destination. Concurrent subset updates can overwrite each other; an interrupted write can leave invalid JSON. A template should demonstrate a dependable persistence pattern.
Acceptance criteria
Serialize the complete read–merge–persist operation for concurrent requests within the supported deployment model.
Write to a temporary file in the same directory and atomically replace the destination.
Preserve the last valid configuration if persistence fails.
Add a meaningful overlapping-request test showing that updates to different settings are retained, plus a failed-write test.
Document the concurrency guarantee and any multi-process limitation.
Keep the example small and retain bounded input validation and off-event-loop filesystem work.
my-plugin/routes.py now serializes the full read–merge–persist with an asyncio.Lock held across asyncio.to_thread, and persists via a temp file in the same directory + os.replace, so concurrent subset POSTs can't lose each other's updates and a failed write preserves the last valid config (temp file cleaned up, request returns 500). Added an overlapping-request test (a lock-disabled harness confirmed it fails 20/20 runs without the lock) and a failed-write test; documented the single-process guarantee, the multi-process limitation, and the 0600 file-mode side effect in my-plugin/README.md + AGENTS.md. The TestClient fixture now runs as a context manager so all requests share one event loop — required for the lock.
All 21 tests pass plus the CI-equivalent manifest/JS/print checks. A pre-commit reviewfrog pass found no blocking issues; its two doc-level findings were addressed, its dir-fsync and test-hook suggestions were rejected as ceremony for a template.
Activity
pullfrog commentedon Oct 13, 2026
pullfrog commentedon Oct 16, 2026
Implemented issue #14 in PR #17: #17
my-plugin/routes.pynow serializes the full read–merge–persist with anasyncio.Lockheld acrossasyncio.to_thread, and persists via a temp file in the same directory +os.replace, so concurrent subsetPOSTs can't lose each other's updates and a failed write preserves the last valid config (temp file cleaned up, request returns500). Added an overlapping-request test (a lock-disabled harness confirmed it fails 20/20 runs without the lock) and a failed-write test; documented the single-process guarantee, the multi-process limitation, and the0600file-mode side effect inmy-plugin/README.md+AGENTS.md. TheTestClientfixture now runs as a context manager so all requests share one event loop — required for the lock.All 21 tests pass plus the CI-equivalent manifest/JS/print checks. A pre-commit reviewfrog pass found no blocking issues; its two doc-level findings were addressed, its dir-fsync and test-hook suggestions were rejected as ceremony for a template.
Task list (3/6 completed)
big-pickle(free) | 𝕏