我有一个定期运行的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
. 这是可能的吗?

有帮助吗?

解决方案

好的,这对我有用:
job.scheduler.in '5s', self
.
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top