Domanda

Ho un rufus "ogni lavoro" che funziona periodicamente, ma a volte potrebbe non riuscire a eseguire il suo compito.

Sul fallimento, vorrei riprogrammare un tentativo di tentare presto piuttosto che aspettare il ciclo successivo.

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
.

è possibile?

È stato utile?

Soluzione

OK questo funzionava per me:

job.scheduler.in '5s', self
.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top