Skip to content

About

Unix process locks and atomic text publication in Mojo

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

filelock-mojo

CodeQL

Shared/exclusive Unix process locks, atomic UTF-8 writes and bounded locked reads in native Mojo. Owners are move-only; guards borrow them.

Install

With Pixi:

pixi init my-project
cd my-project
pixi workspace channel add https://repo.prefix.dev/modular-community https://conda.modular.com/max
pixi add filelock-mojo

Save as example.mojo, then run pixi run mojo run example.mojo:

from filelock_mojo import atomic_write, locked_read

def main() raises:
    atomic_write("checkpoint.txt", "step=42\n")
    print(locked_read("checkpoint.txt", max_bytes=4096))

Use a trusted local filesystem and the same stable lock file in every process. Do not unlink or replace the lock file, or share an owner across threads. Atomic writes preserve the old file if publication fails; they do not promise power-loss durability. Windows and cross-host locking are unsupported.

Version 0.1.0 packages use Mojo 1.1.0 on macOS ARM64. Source checks also cover 1.2.0.dev2026100905; Linux is experimental.

API · Compatibility · Checks. Run uv run python tools/check_all.py to verify the checkout.

MIT. Inspired by Python filelock; see notices and its unchanged license.

About

Unix process locks and atomic text publication in Mojo

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages