fl00r/pickup

Infinite loop

juyeong opened this issue · 0 comments

there is an infinite loop

here is an example

require 'timeout'

error_count = 0
20.times do
  begin
    arr = [
      { k: 'a', w: 5 }, { k: 'b', w: 4 }, { k: 'c', w: 3 }
    ]
    Timeout::timeout(1) {
      key_func = Proc.new { |i| i[:k] }
      weight_func = Proc.new { |i| i[:w] }
      pickup = Pickup.new(arr, key_func: key_func, weight_func: weight_func, uniq: true)
      pickup.pick(2)
    }
  rescue => e
    puts e
    error_count += 1
  end
end
puts "error: #{error_count} times"