On 17 Nov, 2014, at 08:45, Jerry Krinock <je...@ieee.org> wrote:
>> On 2014 Nov 17, at 11:04, Damien Sorresso <dsorre...@apple.com> wrote:
>> 
>> I'm not sure I'm grokking what you're after to be honest.
> 
> Yes I agree.  Please allow me to try again, from scratch…
> 
> My requirement is to read data from a watched file and process it whenever 
> that file changes.  Such a change typically occurs only several times a day, 
> often in bursts of several changes during a few minutes.  Some days there may 
> be no changes at all.  Furthermore, my processing is not urgent.  If the 
> watched file changes three times within a minute, I can be lazy and process 
> all changes at once, a minute or two after the third change has completed.

Yeah... that is not what ThrottleInterval is for. 

> It seems that having a service (process) running 24/7 for this need would be 
> wasteful.  Instead, I use launchd with a WatchPath to launch the tool 
> whenever a change is detected.  Furthermore, I use ThrottleInterval to 
> coalesce multiple changes into one running of my tool.  Finally, my tool does 
> not even have anything like a run loop to keep it running.  It just has a 
> main() that reads the file, processes the data, and exits, typically after 10 
> seconds.

launchd can't really implement this behavior for you since it does not know 
what your program is doing. If this is the behavior you want, you should have 
your program watch the file for changes itself using dispatch(3) sources. In 
other words, you should be using a run loop to watch for the events you're 
interested in.

> So you see there is no “requisite minimum time” for my program to run.  The 
> faster it runs, the better!
> 
> * * *
> 
> The issue is that the ThrottleInterval gives me these warnings, because it is 
> geared toward “amortizing startup”, instead of minimizing running.  Should I 
> be doing things differently?

Yes, you want a run loop.
-damien

_______________________________________________
launchd-dev mailing list
launchd-dev@lists.macosforge.org
https://lists.macosforge.org/mailman/listinfo/launchd-dev

Reply via email to