[Backgroundrb-devel] Jobs running too slow

Jason LaPier jason.lapier at gmail.com
Fri Dec 21 11:32:35 EST 2007

On Dec 21, 2007 2:26 AM, Joe Van Dyk <joevandyk at gmail.com> wrote:
> On Dec 21, 2007 2:07 AM, hemant kumar <gethemant at gmail.com> wrote:
> > On Thu, 2007-12-20 at 23:17 -0800, Joe Van Dyk wrote:
> > > Say I have a job that runs every minute, but it takes longer than a
> > > minute to execute.  Will it start a new job every minute?
> > >
> > > If it does, then how would I make a job that sleeps for a certain
> > > amount of time, then restarts?  I have a job that could take an hour
> > > or two to complete, and I don't want to have multiple copies of that
> > > job running at the same time.
> >
> >
> > If your job takes longer than a minute to complete and yet you are
> > scheduling it with an interval of one minute and you don't want it to
> > run concurrently, seems like an mutually exclusive case. :)
> Well, say it normally takes 10 seconds, but then sometimes, due to the
> internet being really slow, it takes 5 minutes.  I don't want to be
> running multiple jobs in that scenario, I want to wait for the slow
> job to finish before starting the next one.

Is it a single worker that's always running and periodically kicks off
the job? If so, you could set a variable when the job starts -
something like:

def create
  @in_job = false

def start_the_job
  if @in_job
    return false
    @in_job = true
    # run the job
    # might be in this part for a while
    @in_job = false

- Jason L.

My Rails and Linux Blog: http://offtheline.net

More information about the Backgroundrb-devel mailing list