Permalink
Browse files

style changes on interrupt control

  • Loading branch information...
1 parent 93f7c7c commit d0d2b7f7ecf27244a79fdddcc7f343d931d2fafb @boazavital boazavital committed Oct 20, 2011
Showing with 7 additions and 11 deletions.
  1. +7 −9 lib/gizzard/transformation_scheduler.rb
  2. +0 −2 lib/gizzmo.rb
@@ -223,16 +223,14 @@ def time_elapsed
# Trap interrupt (Ctrl+C) for better/safer handling
def control_interrupts
- num_interrupts = 0
- max_interrupts = 3
- trap("INT") do
- if num_interrupts == 0
+ ints_left = 3
+ trap("INT") do
+ ints_left -= 1
+ if !@jobs_pending.empty?
# get rid of scheduled jobs
puts "\nINTERRUPT RECEIVED! Cancelling jobs not yet started. Finishing jobs in progress..."
@jobs_pending.clear
end
- num_interrupts +=1
- ints_left = max_interrupts - num_interrupts
if ints_left > 0
puts "\nPress Ctrl+C #{ints_left} more time#{'s' if ints_left > 1} to terminate jobs in progress. This is dangerous."
end
@@ -241,8 +239,8 @@ def control_interrupts
elsif ints_left == 0
puts "\nTerminating on interrupt..."
exit 1
- end#if
- end#trap
- end#def
+ end
+ end
+ end
end
end
View
@@ -31,7 +31,6 @@ class HelpNeededError < RuntimeError; end
"wrap" => "Wrapping creates a new (virtual, e.g. blocking, replicating, etc.) shard, and relinks SHARD_ID_TO_WRAP's parent links to run through the new shard.",
}
-
ORIGINAL_ARGV = ARGV.dup
zero = File.basename($0)
@@ -47,7 +46,6 @@ class HelpNeededError < RuntimeError; end
# Leftover arguments
argv = nil
-
GIZZMO_VERSION = File.read(File.dirname(__FILE__) + "/../VERSION") rescue "unable to read version file"
begin

0 comments on commit d0d2b7f

Please sign in to comment.