Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --smoothing parameter for watchmedo --command to smooth over / ignore multiple triggering events. #231

Closed
wants to merge 1 commit into from

Conversation

nuket
Copy link

@nuket nuket commented Apr 10, 2014

No description provided.

@nuket nuket changed the title Add --smoothing parameter for watchmedo --command to ignore smooth over ... Add --smoothing parameter for watchmedo --command to ignore smooth over / ignore multiple triggering events. Apr 10, 2014
@nuket
Copy link
Author

nuket commented Apr 10, 2014

Changes relate to Issue #136, which relates to a problem I was having with a software development IDE. Whenever the IDE makes changes to a source file, it generates more than a single filesystem event, and triggers multiple automatic builds.

Using a --smoothing=<seconds> parameter will cause the first triggering event to be fired after <seconds> have passed, and after the extra/interim-detected filesystem events have been cleared out of the api.py::dispatch_events::event_queue.

@nuket nuket changed the title Add --smoothing parameter for watchmedo --command to ignore smooth over / ignore multiple triggering events. Add --smoothing parameter for watchmedo --command to smooth over / ignore multiple triggering events. Apr 10, 2014
@tamland
Copy link
Collaborator

tamland commented Apr 10, 2014

HI. I'm not sure there's any need for this in the core api. Can you not add it in ShellCommandTrick or other tricks? If I've understood #136 correctly, people just want all events that occur during the execution of shell command to be skipped. There shouldn't be any need for delays or anything to be added to the python api.

time.sleep(self._smoothing)

if not event_queue.empty():
print("Smoothing over / ignoring {0} filesystem events that arrived after the triggering event.".format(event_queue.qsize()))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

possible race condition here

@nuket
Copy link
Author

nuket commented Apr 10, 2014

I can give it a shot. The reason I believed I needed to add the smoothing parameter to drain the event_queue all the way down in the API level is because I've tried using --wait and --no-parallel on the ShellCommandTrick, and it doesn't work as I would expect.

i.e. Using both parameters at the same time would lead me to believe that the command would "avoid multiple simultaneous instances" and "ignore events that happen while the previous process is still running". So it should run the command a single time, and ignore events that happen while that command is running.

But what I see instead is the command being run serially multiple times when I do a touch * on a watched directory's contents.

@tamland
Copy link
Collaborator

tamland commented Apr 10, 2014

On second thought: doesn't --no-parallel actually implement this? (awful name). https://github.com/gorakhargosh/watchdog/blob/master/src/watchdog/tricks/__init__.py#L94 returns immediately while the command is running. Author notes "This causes events that arrive while a process is still running to be silently ignored".

Don't use --wait and --no-parallel simultaneously though. Then I think you have misunderstood. --wait will just wait for the command to finish before processing the next event (conflicting with --no-parallel).

@nuket
Copy link
Author

nuket commented Apr 10, 2014

Ok, yes, that works. Meaning Issue #136 can be closed. But yeah, not the best naming.

@tamland tamland closed this Apr 10, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants