I created a program that parses a text file and loads the data in parallel. When the boot method starts in 9 or less threads, the program does not have an error. But when the method starts in 10 or more threads, the program throws an initialize error: getaddrinfo: name or service is unknown (SocketError). I tried several algorithms for parallel operation, but the same problem arises. I placed the url that was passed to the "open" (open-uri) method when the "Name or service is unknown" error occurred in the browser, and confirmed that this URL was valid and received the correct data. See Partial Code.
jobs = []
aps = []
....
....
max_thread = 15
loop do
ary_threads = []
max_thread.times do |i|
break if jobs.size == 0
job = jobs.pop
ary_threads << Thread.start {
begin
request(job[0],job[1]).each do |ap|
aps.push(ap)
end
end
}
end
ary_threads.each { |th| th.join }
break if jobs.size == 0
end
and mistake
/usr/lib/ruby/1.9.1/net/http.rb:762:in `initialize': getaddrinfo: Name or service not known (SocketError)
from /usr/lib/ruby/1.9.1/net/http.rb:762:in `open'
from /usr/lib/ruby/1.9.1/net/http.rb:762:in `block in connect'
from /usr/lib/ruby/1.9.1/timeout.rb:54:in `timeout'
from /usr/lib/ruby/1.9.1/timeout.rb:99:in `timeout'
from /usr/lib/ruby/1.9.1/net/http.rb:762:in `connect'
from /usr/lib/ruby/1.9.1/net/http.rb:755:in `do_start'
from /usr/lib/ruby/1.9.1/net/http.rb:744:in `start'
from /usr/lib/ruby/1.9.1/open-uri.rb:306:in `open_http'
from /usr/lib/ruby/1.9.1/open-uri.rb:775:in `buffer_open'
from /usr/lib/ruby/1.9.1/open-uri.rb:203:in `block in open_loop'
from /usr/lib/ruby/1.9.1/open-uri.rb:201:in `catch'
from /usr/lib/ruby/1.9.1/open-uri.rb:201:in `open_loop'
from /usr/lib/ruby/1.9.1/open-uri.rb:146:in `open_uri'
from /var/lib/gems/1.9.1/gems/open-uri-cached-0.0.5/lib/open-uri/cached.rb:10:in `open_uri'
from /usr/lib/ruby/1.9.1/open-uri.rb:677:in `open'
from /usr/lib/ruby/1.9.1/open-uri.rb:33:in `open'
from Test1.rb:42:in `request'
from Test1.rb:77:in `block (3 levels) in <main>'
? - ?
, !
3 .
"open" "" "begin ~ rescue ~ retry ~ end", , "open" . .
begin
response = open(url)
rescue Exception
puts url
puts "retrying"
retry
end
URL- URL- " " :)
.