Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

is this library nonblocking? #22

Open
ilovemysillybanana opened this issue Dec 10, 2018 · 0 comments
Open

is this library nonblocking? #22

ilovemysillybanana opened this issue Dec 10, 2018 · 0 comments

Comments

@ilovemysillybanana
Copy link

ilovemysillybanana commented Dec 10, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant