From 8d7ddaf35a8d166cea4c3d58c79c76efbb930f24 Mon Sep 17 00:00:00 2001 From: Nick Elser Date: Sun, 12 Apr 2015 20:57:29 -0700 Subject: [PATCH] move logic around loop counts to a more reasonable location --- lib/suo/client/base.rb | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/suo/client/base.rb b/lib/suo/client/base.rb index f6dc8be..459a7ba 100644 --- a/lib/suo/client/base.rb +++ b/lib/suo/client/base.rb @@ -125,8 +125,6 @@ module Suo fail "Client required" unless options[:client] - options[:retry_count] = (options[:retry_timeout] / options[:retry_delay].to_f).ceil - options end @@ -149,13 +147,13 @@ module Suo end def retry_with_timeout(key, options) + count = (options[:retry_timeout] / options[:retry_delay].to_f).ceil + start = Time.now.to_f - options[:retry_count].times do - if options[:retry_timeout] - now = Time.now.to_f - break if now - start > options[:retry_timeout] - end + count.times do + now = Time.now.to_f + break if now - start > options[:retry_timeout] synchronize(key, options) do yield