#1190·watchdog

docs: add more real-world example scripts

Author: prateek-dagarCreated Aug 4, 2026Updated Sep 7, 2026
LabelsdocumentationHelp welcome :)Good first issue

Description

Following our efforts to improve the documentation and the introduction of the new Examples page, we want to expand our gallery of practical, real-world watchdog configurations.

We would like to invite first-time contributors to add clean, executable example Python scripts for common use cases.

How to contribute:

  1. Choose/Propose a Use Case:

  2. Add a Python script: Create a new Python script under docs/source/examples/ (e.g. docs/source/examples/renaming.py). Make sure it is self-contained and clean.

  3. Link to the docs: Open docs/source/examples.rst and include your script using the literalinclude directive:

    rst
    .. literalinclude:: examples/renaming.py
       :language: python
       :linenos:
  4. Register in tests: Open tests/test_examples.py and add your example script name to the list of tested files so that it gets automatically tested in CI/CD.

  5. Open a PR!

Suggested Example Ideas for Contributors:

Here are some high-value real-world examples currently missing from our docs:

  • Multi-Directory Monitoring: Monitoring multiple distinct directories with a single Observer and labeled handlers. (PR #1269 by @hugosmoreira)
  • Context Manager (with Observer()): Demonstrating modern Python with statement syntax for automatic start/stop observer lifecycle.(PR #1267 by @Kiveiru3)
  • Auto-Restart / Live-Reload: Automatically restarting a script or subprocess when monitored source files change.(PR #1268 by @Dheekshi-07)
  • Asyncio / Event Loop Integration: Bridging watchdog filesystem events into an asyncio event loop.(PR #1273 by @subikshajegadish)
  • AutoRestartTrick Example: Automatically restarting a long-running subprocess (e.g. web server or worker) when monitored source files change.
  • ShellCommandTrick Example: Executing automated build/test commands (like running pytest or a linter) when files are created/modified.(PR #1270 by @Larslllllll)
  • Custom Trick Subclass: Building a reusable, pattern-matched Trick that works programmatically and via watchmedo tricks.yaml.(PR #1272 by @MOHAMEDB999)
  • Event Batching / Coalescing: Using a background worker queue or debounce pattern to process filesystem events in batches.

When opening your PR, please include:

Contributes to #1190 (Multi-Directory Monitoring Example)

(Please ensure to review our Examples Documentation and existing scripts in docs/source/examples/ before proposing. If you have a novel use case that is not listed above or already covered, feel free to propose it by commenting below or opening a draft PR to discuss!)