1

我有一个定期运行的 Rufus “每项工作”,但有时它可能无法执行它的任务。

如果失败,我想尽快重新安排重试,而不是等到下一个周期。

class PollProducts

  def initialize()
  end

  def call(job)
    puts "Updating products"

    begin
      # Do something that might fail
      raise if rand(3) == 1
    rescue Exception => e
      puts "Request failed - recheduling: #{e}"
      # job.in("5s") <-- What can I do?
    end
  end
end

scheduler.every '6h', PollProducts.new, :first_in => '5s', :blocking => true

这可能吗?

4

1 回答 1

2

好的,这对我有用:

job.scheduler.in '5s', self
于 2012-03-02T00:06:06.940 回答