Method: VCloud::Task#wait_to_finish

Defined in:
lib/vcloud/user/task.rb

#wait_to_finish(timeout = 60 * 10) { ... } ⇒ Object

Wait until the status of the task is set to indicate that the task has completed

Parameters:

  • timeout (Integer) (defaults to: 60 * 10)

    Timeout in seconds

Yields:

  • Block to run upon completion or the timeout is reached, whichever comes first



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/vcloud/user/task.rb', line 22

def wait_to_finish(timeout = 60 * 10) 
  first_run = true
  Timeout::timeout(timeout) do        
    until @@completed_statuses.include?(self.status)
      sleep 3 if not first_run
      refresh    
      first_run = false
    end
  end
  yield(self) if block_given?
end