[Backgroundrb-devel] Canceling work...

John Wells lists at sourceillustrated.com
Mon Feb 18 12:59:05 EST 2008


On Feb 18, 2008 8:45 AM, hemant <gethemant at gmail.com> wrote:

> On Sun, Feb 17, 2008 at 11:08 PM, John Wells
> <lists at sourceillustrated.com> wrote:
> > Guys,
> >
> > Is there any sort of mechanism for canceling workers? I've looked
> through
> > the docs and don't see any but may be overlooking.
> >
>
> What you mean by canceling the job? You mean the one scheduled or one
> from queue?


Well, when I sent this, it was to cancel a job that was started on an
autostarted worker with ask_work. However, I've since changed the worker to
not autostart. I then do call:

# controller action to start
def start_work
  MiddleMan.new_worker(:worker=>"my_worker")
  MiddleMan.ask_work(:worker=>"my_worker", :worker_method=>"my_method")
end

# controller action to stop
def stop_work
  MiddleMan.delete_worker(:worker=>"my_worker")
end

This seems to work, but there are a few undesired things left dangling, as I
haven't found a way to "catch" the delete request and do a cleanup. Assuming
this is impossible, is there any way to clear the last status registered by
the worker with register_status if that worker is deleted?

And, is the above the proper way of cancelling work?

Thanks very much for your help!

John

<http://www.greatworx.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20080218/4d0b8380/attachment.html 


More information about the Backgroundrb-devel mailing list