From: wmorgan Date: Fri, 11 May 2007 05:34:41 +0000 (+0000) Subject: added no-threads option to sup, which might be useful for debugging weird backtraces X-Git-Url: https://git.notmuchmail.org/git?a=commitdiff_plain;h=58e9f5c7ec21e88bb709681dab6f7f695cac8af7;p=sup added no-threads option to sup, which might be useful for debugging weird backtraces git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@396 5c8cc53c-5e98-4d25-b20a-d8db53a31250 --- diff --git a/bin/sup b/bin/sup index c565a78..e9638db 100644 --- a/bin/sup +++ b/bin/sup @@ -2,8 +2,22 @@ require 'rubygems' require 'ncurses' +require 'trollop' require "sup" +$opts = Trollop::options do + version "sup v#{Redwood::VERSION}" + banner < ibuf.content_height, :when_done => lambda { reporting_thread { sleep 1; PollManager.poll } } - PollManager.start_thread + PollManager.start_thread unless $opts[:no_threads] until $exception bm.draw_screen diff --git a/lib/sup.rb b/lib/sup.rb index 71c274f..fd898ae 100644 --- a/lib/sup.rb +++ b/lib/sup.rb @@ -30,16 +30,20 @@ module Redwood ## record exceptions thrown in threads nicely $exception = nil def reporting_thread - ::Thread.new do - begin - yield - rescue Exception => e - File.open("sup-exception-log.txt", "w") do |f| - f.puts "--- #{e.class.name} at #{Time.now}" - f.puts e.message, e.backtrace + if $opts[:no_threads] + yield + else + ::Thread.new do + begin + yield + rescue Exception => e + File.open("sup-exception-log.txt", "w") do |f| + f.puts "--- #{e.class.name} at #{Time.now}" + f.puts e.message, e.backtrace + end + $exception ||= e + raise end - $exception ||= e - raise end end end