Module: WinRM::Shells::Retryable

Included in:
Base
Defined in:
lib/winrm/shells/retryable.rb

Overview

Shell mixin for retrying an operation

Constant Summary collapse

RETRYABLE_EXCEPTIONS =
lambda do
  [
    Errno::EACCES, Errno::EADDRINUSE, Errno::ECONNREFUSED, Errno::ETIMEDOUT,
    Errno::ECONNRESET, Errno::ENETUNREACH, Errno::EHOSTUNREACH, ::WinRM::WinRMWSManFault,
    ::WinRM::WinRMHTTPTransportError, ::WinRM::WinRMAuthorizationError,
    HTTPClient::KeepAliveDisconnected, HTTPClient::ConnectTimeoutError
  ].freeze
end

Instance Method Summary collapse

Instance Method Details

#retryable(retries, delay) ⇒ Object

Retries the operation a specified number of times with a delay between

Parameters:

  • retries (Integer)

    The number of times to retry

  • delay (Integer)

    The number of seconds to wait between retry attempts



34
35
36
37
38
39
40
41
# File 'lib/winrm/shells/retryable.rb', line 34

def retryable(retries, delay)
  yield
rescue *RETRYABLE_EXCEPTIONS.call
  raise unless (retries -= 1) > 0

  sleep(delay)
  retry
end