Skip to main content

larzwatch

Portable, poll-based file & directory watching. Pure Python, zero dependencies.

Detect when files are created, modified, or deleted, and react. It works by comparing snapshots of modification times, so it has no native dependencies and behaves identically on every OS (where watchdog needs platform backends). Run a blocking loop, a background thread, or - crucially for tests - call poll() yourself and inspect the changes.

from larzwatch import Watcher

w = Watcher("src", patterns=["*.py"])
w.on_change(lambda c: print(c.type, c.path))   # 'created' / 'modified' / 'deleted'
w.watch(interval=1)          # blocking; or w.start() for a background thread

Why

  • No native backends. watchdog is great but ships OS-specific extensions; larzwatch is pure Python and works the same everywhere - handy for CI, weird filesystems, and locked-down environments. Polling is perfectly fine for reload-on-change, build triggers, and config reloading.
  • Testable. poll() returns the exact list of Change(type, path) since the last call, so you unit-test file-change logic without threads or sleeps.
  • Filtered & recursive. patterns=["*.py", "*.toml"] and recursive=True/False.
  • Zero dependencies.

Install

pip install larzwatch

Usage

from larzwatch import Watcher

w = Watcher("config", patterns=["*.yaml"])
w.on_change(reload_config)

# blocking loop
w.watch(interval=0.5)

# or background + your own loop
w.start(interval=0.5)
...
w.stop()

# or drive it yourself (tests, cron)
for change in w.poll():
    print(change.type, change.path)

Tests

python -m unittest discover -s tests -v   # 9 tests incl. create/modify/delete + background

The Larz stack

One of 30+ pure-Python, zero-dependency libraries at github.com/larz-scripter.

License

MIT (c) larz-scripter

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

larzwatch-0.1.0.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

larzwatch-0.1.0-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file larzwatch-0.1.0.tar.gz.

File metadata

  • Download URL: larzwatch-0.1.0.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.13

File hashes

Hashes for larzwatch-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5f1b3cde4ed5e5dc586d720136e1a379fb83619817da5d07fef9ed3e63020510
MD5 db5972582bd4215b7f79044d0260516b
BLAKE2b-256 95895cbaad10abbea00215803443efc5381d085b07f81789b815b8ebcc03adbe

See more details on using hashes here.

File details

Details for the file larzwatch-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: larzwatch-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.13

File hashes

Hashes for larzwatch-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 06d74d44b5a0e01cd8993d29c700c9b42a00c88ebb8634a3416aff3a449a325e
MD5 2c0cd98d6d2d1eb08665c37a10541088
BLAKE2b-256 e220b4788e5edc2af1a98e7be7a9f86f0ac928c0fbf86d699db900ebb8f8735d

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page