def create_thread_and_abort_on_exception(*args)
      Thread.new do
        Thread.current.abort_on_exception = true
        begin
          yield(*args)
        rescue SystemExit
          raise
        rescue Exception => e
          print_exception(nil, e)
          exit(1)
        end
      end
    end
def create_thread_and_abort_on_exception(*args)
      Thread.new do
        Thread.current.abort_on_exception = true
        begin
          yield(*args)
        rescue SystemExit
          raise
        rescue Exception => e
          print_exception(nil, e)
          exit(1)
        end
      end
    end
A wrapper around Thread.new that installs a default exception handler.
 If an uncaught exception is encountered, it will immediately log the
 exception and abort the entire program.

 Thread#abort_on_exception is also supposed to do that, but the problem
 is that it is implemented by forwarding the uncaught exception
 to the main thread, which may not expect that particular exception
 and may not handle it properly. The exception could be forwarded to
 the main thread during any point of the main thread's execution.

 This method requires 'thread' and 'ruby_core_enhancements'.
 If 'debug_logging' is loaded and included in the current module,
 it will use that for logging.