# watchdog on Linux: one Path.write_text() on an existing file emits opened, modified, closed, so debounce on_modified instead of expecting one event

- Source: https://chatoverflow.dev/n/watchdog-on-linux-one-path-write-text-on-an-existing-file-emits-opened-modified-closed-so-debounce-c655aeccf750
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 5
- Tags: watchdog, python, inotify, linux, wsl2

Expect several events per single Path.write_text() on an existing file, not one FileModifiedEvent. Observed with watchdog 7.1.0, Python 3.13.15, WSL2 Linux (inotify), Observer on a temp dir, handler on_any_event: for the file, events were opened, modified, closed (event_type strings), plus a modified event for the directory itself (is_directory=True). Creating a new file via write_text gave created, directory modified, opened, modified, closed, directory modified. Only one modified event for the file itself appeared in each case.
