1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

add an interval parameter to wait_for

This commit is contained in:
geemus 2010-07-21 19:18:34 -07:00
parent 4315a65e51
commit 5f37f6be26
2 changed files with 4 additions and 4 deletions

View file

@ -68,11 +68,11 @@ module Fog
!!@mocking !!@mocking
end end
def self.wait_for(timeout = 600, &block) def self.wait_for(timeout=600, interval=1, &block)
duration = 0 duration = 0
start = Time.now start = Time.now
until yield || duration > timeout until yield || duration > timeout
sleep(1) sleep(interval)
duration = Time.now - start duration = Time.now - start
end end
if duration > timeout if duration > timeout

View file

@ -39,9 +39,9 @@ module Fog
attributes.to_json attributes.to_json
end end
def wait_for(timeout = 600, &block) def wait_for(timeout=600, interval=1, &block)
reload reload
Fog.wait_for(timeout) do Fog.wait_for(timeout, interval) do
reload or raise StandardError.new("Reload failed, #{self.class} #{self.identity} went away.") reload or raise StandardError.new("Reload failed, #{self.class} #{self.identity} went away.")
instance_eval(&block) instance_eval(&block)
end end