-
Notifications
You must be signed in to change notification settings - Fork 257
Open
Description
Line 92 in 4fe8381
| @source = source.to_a unless @lambda # turn Range and other Enumerable-s into an Array |
Parallel provides each and map methods, implying it works well with Enumerables, but it fails with the following [contrived] use case:
require 'parallel'
require 'prime'
primes = Prime.to_enum
private_key = 12344567899
Parallel.each(primes, in_threads: 16) do |prime|
if private_key % prime == 0
puts "Found factor: #{prime}"
raise Parallel::Break
end
end...because if the first argument to Parallel.each is not a lambda, .to_a is called and it tries to expand the infinite series.
mikecmpbll
Metadata
Metadata
Assignees
Labels
No labels