2010-12-16 14:24:52 -05:00
|
|
|
module Fog
|
2011-07-11 18:06:47 -04:00
|
|
|
def self.wait_for(timeout=Fog.timeout, interval=1, &block)
|
2010-12-16 14:24:52 -05:00
|
|
|
duration = 0
|
|
|
|
start = Time.now
|
|
|
|
until yield || duration > timeout
|
2011-11-30 12:35:13 -05:00
|
|
|
sleep(interval.to_f)
|
2010-12-16 14:24:52 -05:00
|
|
|
duration = Time.now - start
|
|
|
|
end
|
|
|
|
if duration > timeout
|
2012-12-12 16:35:41 -05:00
|
|
|
raise Errors::TimeoutError.new("The specified wait_for timeout (#{timeout} seconds) was exceeded")
|
2010-12-16 14:24:52 -05:00
|
|
|
else
|
|
|
|
{ :duration => duration }
|
|
|
|
end
|
|
|
|
end
|
2011-07-09 20:47:49 -04:00
|
|
|
end
|