A
Aldric Giacomoni
Example code, on Ruby 1.8.6:
require 'resolv'
t0 = Time.now
(1..500).each do |a|
begin
a = Resolv:
NS.new.getaddress("www.example.dom").to_s
rescue Resolv::ResolvError
a = "Hahahahaa"
end
end
puts "#{(Time.now - t0) / 500} second per."
Error:
c:/ruby/lib/ruby/1.8/resolv.rb:572:in `initialize': Too many open files
(Errno::EMFILE)
___________________
How can I prevent this error from happening? Can I do manual garbage
collection and delete each DNS.new Object at the end of each iteration?
Is there a better idea out there?
Thanks,
--Aldric
require 'resolv'
t0 = Time.now
(1..500).each do |a|
begin
a = Resolv:
rescue Resolv::ResolvError
a = "Hahahahaa"
end
end
puts "#{(Time.now - t0) / 500} second per."
Error:
c:/ruby/lib/ruby/1.8/resolv.rb:572:in `initialize': Too many open files
(Errno::EMFILE)
___________________
How can I prevent this error from happening? Can I do manual garbage
collection and delete each DNS.new Object at the end of each iteration?
Is there a better idea out there?
Thanks,
--Aldric