Skip to content

watchdog runs too many times / repeatedly when many files are changed #542

@MareoRaft

Description

@MareoRaft

I am using watchdog to watch a git repository and rerun a build process every time the repo changes.

I have observed that performing a git pull, for example, can cause watchdog to run repeatedly. I believe that the git pull is causing a very large number of files to change, and hence watchdog runs many times because watchdog runs once per file modification.

For me, this is not the desired behavior. If 5 files are modified at the same time, for example, I only need watchdog to run the build process once. I am hoping we can add a configuration option to watchdog to allow somebody to opt-in to the following proposed behavior "lazy run":

Proposed behavior "lazy run":

  • Watchdog maintains a queue of file change events. This happens concurrently.
  1. Check the queue.
  2. If the queue is nonempty, empty the queue and run the process.
  3. (When the process is finished,) return to step 1.

Example of "lazy run" in action:

Suppose that the process to run takes a long time, and 5 files are modified in rapid succession.

  1. First file modified.
  2. modification 1 goes in queue
  3. watchdog empties queue and begins running the process
  4. Second file modified
  5. Third file modified
  6. Fourth file modified
  7. Fifth file modified
  8. modifications 2 through 5 are in the queue.
  9. The process completes and watchdog checks the queue again
  10. Modifications are discarded from the queue and watchdog begins running the process again
  11. The process completes again.

As you can see, in this example, even though 5 files were modified, the process only runs 2 times.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions