Skip to content

Infinite loop #6

@juyeong

Description

@juyeong

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"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions