fcntl does not exist on Windows, so memo crashed on import. Guard the import and use msvcrt advisory locking with spin/backoff; open the lock file in append mode so parallel sessions don't break each other's locks. Verified: 8 parallel processes x 200 notes = 1600/1600 records on native Windows (no WSL).
818 B
818 B
Windows support
OptMem now runs on native Windows (no WSL required).
What changed
import fcntlis guarded — falls back toNoneon platforms without it.locked()usesmsvcrtadvisory locking with spin/backoff whenfcntlis unavailable, so parallel sessions (the documented multi-process case) queue instead of raisingResource deadlock avoided.- The
.lockfile is opened in append mode ("a") rather than"w", which would truncate and break locks held by other processes on Windows.
Test (Windows native, no WSL)
python memo init
set MEMORY_DIR=C:\path\to\mem
python memo note "first memory"
python memo note "second memory"
python memo wake
Concurrency: 8 parallel memo note processes writing 1600 memories
resulted in 1600/1600 records persisted (lock verified).