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 = Loog::NULL) ⇒ VerboseThread

Returns a new instance of VerboseThread.



18
19
20
# File 'lib/zold/verbose_thread.rb', line 18

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

Instance Method Details

#run(safe: false) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/zold/verbose_thread.rb', line 22

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