Exception: ProcessExecuter::Command::TimeoutError

Inherits:
SignaledError show all
Defined in:
lib/process_executer/command/errors.rb

Overview

Raised when the command takes longer than the configured timeout

Examples:

result.status.timeout? #=> true

Instance Attribute Summary collapse

Attributes inherited from CommandError

#result

Instance Method Summary collapse

Methods inherited from CommandError

#error_message

Constructor Details

#initialize(result, timeout_duration) ⇒ TimeoutError

Create a TimeoutError object

Examples:

command = %w[sleep 10]
timeout_duration = 1
status = ProcessExecuter.spawn(*command, timeout: timeout_duration)
result = Result.new(command, status, 'stdout', 'err output')
error = TimeoutError.new(result, timeout_duration)
error.error_message
  #=> '["sleep", "10"], status: pid 70144 SIGKILL (signal 9), stderr: "err output", timed out after 1s'

Parameters:

  • result (Result)

    The result of the command including the git command, status, stdout, and stderr

  • timeout_duration (Numeric)

    The duration the subprocess was allowed to run before being terminated



144
145
146
147
# File 'lib/process_executer/command/errors.rb', line 144

def initialize(result, timeout_duration)
  @timeout_duration = timeout_duration
  super(result)
end

Instance Attribute Details

#timeout_durationNumeric (readonly)

The amount of time the subprocess was allowed to run before being killed

Examples:

`kill -9 $$` # set $? appropriately for this example
result = Result.new(%w[git status], $?, '', "killed")
error = TimeoutError.new(result, 10)
error.timeout_duration #=> 10

Returns:

  • (Numeric)


159
160
161
# File 'lib/process_executer/command/errors.rb', line 159

def timeout_duration
  @timeout_duration
end