2012-02-28 27 views
1

我有一个定期运行的Rufus“每项工作”,但有时可能无法执行它的任务。如何重新安排失败的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 

这可能吗?

回答

2

好这个工作对我来说:

job.scheduler.in '5s', self 
相关问题