Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix rescue in pop method

  • Loading branch information...
commit 15e80eabd9bd9d024df06ddf4eb1624bdb3c6274 1 parent b10ba9f
@michelson michelson authored
Showing with 6 additions and 5 deletions.
  1. +6 −5 lib/detached_carrot.rb
View
11 lib/detached_carrot.rb
@@ -58,11 +58,13 @@ def self.process(queue, daemonize = true)
def self.pop
return unless CARROT.message_count > 0
- job = CARROT.pop(:ack => true)
- puts "Popping: #{job.inspect}"
- job = JSON.parse(job)
+
begin
# job = autoload_missing_constants { CARROT.get(queue) }
+ job = CARROT.pop(:ack => true)
+ puts "Popping: #{job.inspect}"
+ job = JSON.parse(job)
+ CARROT.ack
options = []
options << job['options'][0].key_strings_to_symbols! unless job['options'][0].nil?
puts " the options are #{options.inspect}"
@@ -78,7 +80,7 @@ def self.pop
CARROT_LOG.warn "[#{Time.now.to_s(:db)}] WARNING #{job['type']}##{job['id']} gone from database."
rescue ActiveRecord::StatementInvalid
CARROT_LOG.warn "[#{Time.now.to_s(:db)}] WARNING Database connection gone, reconnecting & retrying."
- CARROT.publish(job)
+ CARROT.publish(job.to_json)
ActiveRecord::Base.connection.reconnect!
retry
rescue Exception => error
@@ -86,7 +88,6 @@ def self.pop
puts "[#{Time.now.to_s(:db)}] ERROR #{error.message}"
end
- CARROT.ack
end
def self.stats
Please sign in to comment.
Something went wrong with that request. Please try again.