summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/utils.rb21
1 files changed, 20 insertions, 1 deletions
diff --git a/lib/utils.rb b/lib/utils.rb
index 6b32421..3279c29 100644
--- a/lib/utils.rb
+++ b/lib/utils.rb
@@ -28,8 +28,26 @@ module OpenTox
return false
end
end
- end
+ def self.try_again(times=5)
+ count = 0
+ while (true)
+ begin
+ return yield
+ rescue => ex
+ count += 1
+ if count<times
+ LOGGER.warn "failed, try again in a second : "+ex.message
+ sleep 1
+ else
+ raise ex
+ end
+ end
+ end
+ end
+
+ end
+
# ['rubygems', 'rest_client'].each do |r|
# require r
# end
@@ -37,5 +55,6 @@ module OpenTox
# puts u+"? "+Utils.is_uri?(u).to_s
# end
+
end