[Backgroundrb-devel] Suspended start of task not suspended

hemant gethemant at gmail.com
Sat Feb 2 12:00:15 EST 2008


On Feb 2, 2008 10:27 PM, hemant <gethemant at gmail.com> wrote:
>
> 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
>

Also, if you need to set that time dynamically from rails, then you
can pass time as an argument to test_method,

MiddleMan.ask_work(:worker => :foo_worker,:worker_method =>
:test_method, :data => { :firetime => 60,:args => "bar"})

and in test_method

def test_method args
  add_timer(args[:firetime]) { fire_method(args[:args]) }
end


More information about the Backgroundrb-devel mailing list