[Backgroundrb-devel] starting queued worker tasks immediately

Ivan Maltz ivan.maltz at picochannel.com
Sat Nov 7 16:56:29 EST 2009


My application performs a series of image processing tasks on photos. These
are queued up for processing like this

 

    worker = MiddleMan.worker(:photo_worker)

    worker.enq_process_images(:arg => id, :job_key =>
"#{PHOTO_WORKER_KEY}_#{id}" )

 

The background processing is kicked off every minute, as specified in
backgroundrb.yml

  :persistent_delay: 60

 

The images are processed in PhotoWorker like this

 

  def process_images(pid)

    photo = Photo.find(pid)

    photo.do_processing

    persistent_job.finish!

    # this task is done, start the next one

    check_for_enqueued_tasks

  end

 

When adding a new task to an empty queue, I would like to start the
background process immediately, rather than waiting till the next scheduled
execution of the worker.  How can I accomplish this?

 

-Ivan

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20091107/e4dcee34/attachment.html>


More information about the Backgroundrb-devel mailing list