seb-m / pyinotify

Monitoring filesystems events with inotify on Linux.
http://github.com/seb-m/pyinotify/wiki
MIT License
2.29k stars 379 forks source link

Feature Request: Delay/Batch up the events at the CLI #169

Open dagostinelli opened 5 years ago

dagostinelli commented 5 years ago

When using it like so:

./venv/bin/python3 -m pyinotify -r -a -e IN_CLOSE_WRITE -c 'make build' src/

Sometimes I get multiple events in quick succession.

This wreaks havoc because pyinotify spawns sub-processes. This ends up with multiple parallel invocations of make build, resulting in race conditions.

One solution is to work on my Makefile to quickly exit if it detects a parallel invocation. Another is to find some UNIX-ish way to batch up calls to make buid somehow and only when 1 second of no more calls has elapsed, then release just one call to make build. Another solution is that I can submit this issue to you asking for a feature where it delays or batches up events before invoking the command. Here we go.

Ideas:

One wrinkle is how to detect duplicate events in some flexible way. Is it duplicate by file name? Is it duplicate by event only?

Suggestion:

--aggregate=[filename, event, filename_event]