summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authormguetlein <martin.guetlein@gmail.com>2010-05-14 17:44:35 +0200
committermguetlein <martin.guetlein@gmail.com>2010-05-14 17:44:35 +0200
commitcee11eff66938cb65b817ab9595f4386ce5a8eeb (patch)
tree0820784a4db24577ee13149f989750520cd7cb79 /lib
parent5d0d82a2d8eaf1f13db84ba8b5beffaede5bc50a (diff)
debug hacks
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