Class: Mistri::Dispatchers::Thread

Inherits:
Object
  • Object
show all
Defined in:
lib/mistri/dispatchers.rb

Overview

Real in-process background: the child runs on its own thread and the spawn call returns immediately. Enough for development and for hosts whose children are short; queue-backed hosts plug their own lambda.

Instance Method Summary collapse

Instance Method Details

#call(spec, runner) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/mistri/dispatchers.rb', line 33

def call(spec, runner)
  ::Thread.new do
    runner.call
  rescue StandardError => e
    # The runner writes the child's failed terminal before re-raising;
    # a thread must not die loudly into the process, but it must not
    # die silently either, or there is no trace to debug from.
    warn "mistri: background runner for #{spec["name"].inspect} crashed: " \
         "#{e.class}: #{e.message}"
  end
  nil
end