is this library nonblocking?
ilovemysillybanana opened this issue · comments
Jose Manuel Tobar commented
I have list of several thousand machines I need to ping(all on my company network so nothing shady!). Anyway, to speed this up I was trying to run 50 threads in parallel that would ping these nodes but it appears to me that this gem is traversing over itself when I do that.
Here is an example of how I am doing that:
data_queue= queue.new()
consumer = Array.new(50).each do |num|
Thread.new do
unless if queue.empty?
temp = queue.shift
data_queue << [temp, Net::Ping::TCP.new(Temp, 'http')]
end
end
end
consumer.each(&:join)
data_hash = Array.new()
loop do
break if data_queue.empty?
temp = data_queue.shift
data_hash.merge!(temp[0] => temp[1])
end
Anyway, I'm giving it a list of 5000 machines but am only getting 50 unless I'm just confused as to how memory works in threading I think it has to do with this library not being thread safe.