Search code examples
ruby-on-railsrubysidekiq

stop sidekiq worker perform method


I have an begin rescue block in my worker's perform method like this

begin
  HTTParty.get(url)
rescue
  ## call failed for some reason, log and stop performing
  break
end
## do more stuff here with the result of the call if it didn't fail
## this can fail too so a further
  begin
    ##would be cumbersome
  rescue
  end

however I get an Invalid break (SyntaxError)

Is there another way to tell sidekiq that this job is essentially finished? I don't want it to retry but rather just quit completely.


Solution

  • Just return:

    begin
      HTTParty.get(url)
    rescue => e
      logger.warn(e.message)
      return
    end