Class: Zold::VerboseThread

Inherits:
Object
  • Object
show all
Defined in:
lib/zold/verbose_thread.rb

Overview

Verbose thread

Instance Method Summary collapse

Constructor Details

#initialize(log = Log::NULL) ⇒ VerboseThread

Returns a new instance of VerboseThread.



35
36
37
# File 'lib/zold/verbose_thread.rb', line 35

def initialize(log = Log::NULL)
  @log = log
end

Instance Method Details

#run(safe = false) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/zold/verbose_thread.rb', line 39

def run(safe = false)
  Thread.current.report_on_exception = false
  yield
rescue Errno::ENOMEM => e
  @log.error(Backtrace.new(e).to_s)
  @log.error("We are too big in memory (#{Size.new(GetProcessMem.new.bytes.to_i)}), quitting; \
this is not a normal behavior, you may want to report a bug to our GitHub repository")
  abort
rescue StandardError => e
  @log.error(Backtrace.new(e).to_s)
  raise e unless safe
end