Permalink
Browse files

fix rescue in pop method

  • Loading branch information...
1 parent b10ba9f commit 15e80eabd9bd9d024df06ddf4eb1624bdb3c6274 @michelson michelson committed Sep 8, 2009
Showing with 6 additions and 5 deletions.
  1. +6 −5 lib/detached_carrot.rb
View
@@ -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,15 +80,14 @@ 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
CARROT_LOG.error "[#{Time.now.to_s(:db)}] ERROR #{error.message}"
puts "[#{Time.now.to_s(:db)}] ERROR #{error.message}"
end
- CARROT.ack
end
def self.stats

0 comments on commit 15e80ea

Please sign in to comment.