diff --git a/lib/resque/client.rb b/lib/resque/client.rb index f0c92a5fc..32b514ee0 100644 --- a/lib/resque/client.rb +++ b/lib/resque/client.rb @@ -16,28 +16,25 @@ class Client def initialize(backend) @backend = backend - - @reconnected = false end # Reconnect to Redis to avoid sharing a connection with the parent, # retry up to 3 times with increasing delay before giving up. def reconnect - return if @reconnected - tries = 0 begin backend.client.reconnect - @reconnected = true rescue Redis::BaseConnectionError - if (tries += 1) <= 3 - Resque.logger.info "Error reconnecting to Redis; retrying" - sleep(tries) - retry - else + tries += 1 + + if tries == 3 Resque.logger.info "Error reconnecting to Redis; quitting" raise end + + Resque.logger.info "Error reconnecting to Redis; retrying" + sleep(tries) + retry end end end