Watchdog

A Python API and shell utilities for monitoring filesystem events across platforms

Library
PyPI
v6.0.0
7,395stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
81/100Excellent
Development Activity84
Maintenance60
Community80
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
74/100Good
Architecture80
Code Quality75
Innovation68
Learning Curve74

Watchdog is a Python library for monitoring filesystem events - file/directory creation, deletion, modification, and moves - using each platform’s native notification mechanism: inotify on Linux, FSEvents on macOS, kqueue on BSD, and ReadDirectoryChangesW on Windows, with a polling fallback everywhere else. It exposes both an Observer/EventHandler API for embedding filesystem watching directly in Python applications and a watchmedo shell utility for triggering shell commands or auto-restarting processes on file changes, making it a common building block behind live-reload tooling, build watchers, and sync utilities.

What You Get

  • A unified Observer class that dispatches filesystem events to registered EventHandler subclasses regardless of the underlying OS notification API
  • Native backend implementations for inotify (Linux), FSEvents (macOS), kqueue (BSD), and the Win32 ReadDirectoryChangesW API, plus a portable polling observer as a fallback
  • Pattern-matching event handlers (PatternMatchingEventHandler, RegexMatchingEventHandler) for filtering events by filename glob or regex without writing dispatch logic by hand
  • The watchmedo command-line utility for running shell commands, auto-restarting a process, or logging events whenever matched files change, with no Python code required
  • A DirectorySnapshot/DirectorySnapshotDiff API for polling-based change detection when native OS events aren’t available or desired

Common Use Cases

  • Building a live-reload development server that restarts or refreshes when source files change
  • Triggering an incremental build, test run, or sync job automatically whenever files in a watched directory are modified
  • Implementing a file-sync or backup tool that reacts to filesystem changes in near real time instead of polling on a timer
  • Using the watchmedo CLI to wire an arbitrary shell command to file-change events without writing any Python

Under The Hood

Architecture Watchdog centers on src/watchdog/observers, which contains one module per platform backend (inotify.py/inotify_c.py wrapping Linux’s inotify via ctypes, fsevents.py for macOS’s FSEvents, kqueue.py for BSD, read_directory_changes.py/winapi.py for Windows) all conforming to a common BaseObserver interface defined in observers/api.py; the Observer class chosen at import time is simply an alias for whichever backend matches the running platform. Events flow from the backend thread into EventQueue, which dispatches to registered EventHandler subclasses (in src/watchdog/events.py), decoupling event production from consumption. src/watchdog/tricks builds the watchmedo CLI’s shell-command and process-restart behaviors on top of the same handler interface. Polling-based detection (observers/polling.py) uses DirectorySnapshot/DirectorySnapshotDiff to diff directory state between scans as a portable fallback. Tech Stack Python with a thin C extension/ctypes layer for the Linux inotify backend and platform-specific optional dependencies (pyobjc for FSEvents on macOS); packaged via setuptools with cibuildwheel for building platform wheels. Type checking is enforced via a strict mypy configuration (disallow_untyped_defs, warn_unused_ignores) in pyproject.toml. Code Quality The tests/ directory contains 26 test modules exercising each observer backend plus the pattern-matching handlers and directory-snapshot diffing; coverage is tracked via tool.coverage.report config excluding type-checking-only branches. The long single-maintainer-plus-contributors history (gorakhargosh holds the majority of commits, with steady community contributions) reflects a mature, incrementally hardened codebase. API Design The Observer/EventHandler pattern is a small, well-documented surface: subclass EventHandler, override the on_* callbacks you care about, schedule it against a path, and start the observer — this requires little boilerplate for the common case. The pattern-matching handler subclasses (PatternMatchingEventHandler) further reduce boilerplate for the common case of filtering by filename pattern, though users needing to differentiate platform-specific event nuances (e.g. move-event semantics differing between inotify and FSEvents) must dig into backend-specific docs.

Used by 12 apps in this directory

Python
54%
Other

authentik

Authentication · Security

24,980

The self-hosted Identity Provider that replaces Okta, Auth0, and Entra ID with a unified SSO platform supporting SAML, OAuth2/OIDC, LDAP, RADIUS, and WebAuthn.

View details
92
Repo Health
81
Technical
68
Dependency
Built with
Python54%
TypeScript33%
Updated today
Python
68%
Other

AutoGPT

Automation · Productivity · AI Assistants

186,687

Build, deploy, and run autonomous AI agents that automate complex multi-step workflows using a visual block-based graph editor.

View details
93
Repo Health
78
Technical
67
Dependency
Built with
Python68%
TypeScript31%
Updated today
Go
82%
AGPL 3.0

Beta9

Developer Tools · AI Development · Data Engineering

1,746

Run AI workloads at scale with a Pythonic serverless runtime that handles GPU inference, background jobs, and sandboxes with zero infrastructure overhead.

View details
85
Repo Health
78
Technical
69
Dependency
Built with
Go82%
Python17%
Updated today
Rust
52%
Apache 2.0

cocoindex

Data Engineering · AI Development

11,350

An incremental data indexing engine that keeps AI agent context perpetually fresh by reprocessing only what changed.

View details
87
Repo Health
85
Technical
64
Dependency
Built with
Rust52%
Python48%
Updated yesterday
Python
82%
Apache 2.0

codeindex

Developer Tools

271

A temporal code knowledge graph with blast-radius impact scoring, semantic symbol search, and git-history-aware dependency analysis for AI-assisted development — zero required runtime dependencies, SQLite-backed.

View details
63
Repo Health
73
Technical
0
Dependency
Built with
Python82%
HTML18%
Updated 2 months ago
Shell
48%
MIT

Dokku

Devops · Hosting Control Panel

32,105

The smallest PaaS implementation you've ever seen — deploy apps via git push using Docker and Heroku buildpacks on your own server.

View details
93
Repo Health
85
Technical
75
Dependency
Built with
Shell48%
Go48%
Updated today
Python
100%
MIT

Graphify

AI Agents

108,063

A YC-backed, open-source knowledge graph skill for AI coding assistants — type /graphify and it maps your entire project (code, docs, PDFs, images, videos) into a queryable graph instead of grepping through files.

View details
82
Repo Health
73
Technical
78
Dependency
Built with
Python100%
Updated 2 days ago
Python
80%
Apache 2.0

headroom

AI Development · Developer Tools

66,835

Compress everything your AI agent reads — tool outputs, logs, RAG chunks, and files — before it reaches the LLM, achieving 60–95% fewer tokens with the same answers.

View details
84
Repo Health
86
Technical
73
Dependency
Built with
Python80%
Rust14%
Updated today
Python
74%
Apache 2.0

OpenKB

Knowledge Management

3,810

An open-source CLI that compiles raw documents into a structured, interlinked wiki-style knowledge base using LLMs — powered by vectorless, reasoning-based retrieval (PageIndex) instead of a vector database.

View details
77
Repo Health
72
Technical
76
Dependency
Built with
Python74%
TypeScript23%
Updated 4 weeks ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search