我如何重新安排鲁弗斯的失败每项工作?
-
13-11-2019 - |
题
我有一个定期运行的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
. 不隶属于 StackOverflow