Class: Thread

Inherits:
Object
  • Object
show all
Defined in:
lib/puma_cloudwatch/core_ext/thread.rb

Overview

Hack makes sure exceptions in Threads like the one in looper.rb that reports to CloudWatch gets reported instead of silently being swallowed. bugs.ruby-lang.org/issues/6647

Class Method Summary collapse

Class Method Details

.new(*args, &block) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/puma_cloudwatch/core_ext/thread.rb', line 7

def new(*args, &block)
  old_new(*args) do |*bargs|
    begin
      block.call(*bargs)
    rescue Exception => e
      raise if Thread.abort_on_exception || Thread.current.abort_on_exception
      puts "Thread for block #{block.inspect} terminated with exception: #{e.message}"
      puts e.backtrace.reverse.map {|line| "  #{line}"}
    end
  end
end

.old_newObject



5
# File 'lib/puma_cloudwatch/core_ext/thread.rb', line 5

alias old_new new