Question

J'ai un Rufus "chaque travail" qui s'exécute périodiquement, mais parfois il peut ne pas effectuer sa tâche.

En cas d'échec, je voudrais reporter une réessayer bientôt plutôt que d'attendre le prochain cycle.

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

Est-ce possible?

Était-ce utile?

La solution

Ok cela a fonctionné pour moi:

job.scheduler.in '5s', self
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top