Skip to content

Commit

Permalink
Don't modify Thread.abort_on_exception
Browse files Browse the repository at this point in the history
Closes #332.
  • Loading branch information
sferik committed Dec 7, 2012
1 parent 41f07f7 commit 6de998c
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions lib/twitter/core_ext/enumerable.rb
Original file line number Diff line number Diff line change
@@ -1,23 +1,11 @@
module Enumerable

def threaded_map
abort_on_exception do
threads = []
each do |object|
threads << Thread.new { yield object }
end
threads.map(&:value)
threads = []
each do |object|
threads << Thread.new { yield object }
end
end

private

def abort_on_exception
initial_abort_on_exception = Thread.abort_on_exception
Thread.abort_on_exception ||= true
yield
ensure
Thread.abort_on_exception = initial_abort_on_exception
threads.map(&:value)
end

end

0 comments on commit 6de998c

Please sign in to comment.