Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add abort_on_exception to threaded_map

  • Loading branch information...
commit 15c9a7c221f24226c1003b76b287d2b2ed9306cb 1 parent 6228922
@heaven heaven authored committed
Showing with 6 additions and 2 deletions.
  1. +6 −2 lib/twitter/core_ext/enumerable.rb
View
8 lib/twitter/core_ext/enumerable.rb
@@ -1,11 +1,15 @@
module Enumerable
def threaded_map
+ initial_abort_on_exception = Thread.abort_on_exception
+ Thread.abort_on_exception ||= true
threads = []
each do |object|
- threads << Thread.new{yield object}
+ threads << Thread.new { yield object }
end
- threads.map(&:value)
+ values = threads.map(&:value)
+ Thread.abort_on_exception = initial_abort_on_exception
+ values
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.