[Backgroundrb-devel] Suspended start of task not suspended

hemant gethemant at gmail.com
Sat Feb 2 11:57:19 EST 2008


On Feb 2, 2008 9:31 PM, Ivo Dancet <caifara.subscribe at gmail.com> wrote:
> Hi
>
> I thought this should suspend the task by 1 minute, but it starts
> immediately:
>
> MiddleMan.ask_work( :worker => :bar_worker, :worker_method
> => :test_method, :trigger_args => { :start => (Time.now + 1.minute)})
>

I do not think passing trigger_args like that is supported at all. No,
it won't work like that.

> Is the start argument not allowed in the new backgroundrb (mine is at
> rev HEAD (=314))? What can I do about this?


Yes it should be pretty simple to have an implementation like this:

# don't execute the task now, but delay it by half an hour
def test_method(args = nil)
  add_timer(30*60) { run_actual_method(args) }
end

def run_actual_method args
  # execute the delayed task
end

I know, its not probably very elegant, but should suffice.
Let us know, if we missed something in above simplistic implementation.
-- 
Let them talk of their oriental summer climes of everlasting
conservatories; give me the privilege of making my own summer with my
own coals.

http://gnufied.org


More information about the Backgroundrb-devel mailing list