Avoiding duplicate tasks in task-spooler

151 views
Skip to first unread message

Raúl Salinas Monteagudo

unread,
May 16, 2013, 5:25:38 AM5/16/13
to tasks...@googlegroups.com
Hi !
Today I found myself with something like the following, in order to automatically recompile the project upon changes. 

while inotifywait -e modify -r src/ 
do 
   tsp make -C build install 
done


If during the compilation the source is modified again, I want just one compile task to be enqueued.  Although I see there is always a chance for a race condition, do you think it could be easy to prevent tsp to add a task if an equal task is already enqueued? 

My first approach is:

function tspnodup {
 if ! tsp  | grep "queued.*$*"  >/dev/null
then 
 tsp "$@"
else 
  echo rejecting to start dup  job >&2
fi
}

But I wonder if someone else finds interesting and/or easy to implement a flag "--no-duplicate" that prevents duplicate jobs according to some parameters. For example equal command-line and/or working directory etc.

What do you think?  Thanks.

Raúl

Lluís Batlle i Rossell

unread,
May 22, 2013, 3:29:29 PM5/22/13
to tasks...@googlegroups.com
On Thu, May 16, 2013 at 11:25:38AM +0200, Raúl Salinas Monteagudo wrote:
> Today I found myself with something like the following, in order to
> automatically recompile the project upon changes.
>
> *while inotifywait -e modify -r src/ *
> *do *
> * tsp make -C build install *
> *done*
>
>
> If during the compilation the source is modified again, I want just one
> compile task to be enqueued. Although I see there is always a chance for a
> race condition, do you think it could be easy to prevent tsp to add a task
> if an *equal* task is already enqueued?
>
> My first approach is:
>
> *function tspnodup {*
> * if ! tsp | grep "queued.*$*" >/dev/null*
> *then *
> * tsp "$@"*
> *else *
> * echo rejecting to start dup job >&2*
> *fi*
> *}*
>
> But I wonder if someone else finds interesting and/or easy to implement a
> flag "--no-duplicate" that prevents duplicate jobs according to some
> parameters. For example equal command-line and/or working directory etc.
>
> What do you think? Thanks.

Hello Raúl!

Humm I think I never had this problem. :)
The situation looks to me quite strange; and the solution... I guess you'd want
to kill the current build, and start one anew, instead of letting one finish.
Reply all
Reply to author
Forward
0 new messages