From: Toki Toki Date: 2008-07-26T03:25:01+09:00 Subject: Re: Simultaneously URL call, is it possible? S2 wrote: > Toki Toki wrote: >> require 'net/http' >> require 'uri' >> 10.times do >> Thread.new >> {Net::HTTP.get_response(URI.parse('http://www.google.com/'))} >> end > > Yes. > >> Good, I've never used require with array. >> >> But if I run the code above I get an error: url_call.rb:4: odd number >> list for Hash >> >> I think it's because of the curly braces that are viewed like an hash, >> right? I don't know how Thread works in Ruby, but it seems that the >> statements in the curly braces need to be on the same line as Thread.new >> otherwise it give the error above... > > Thread.new gets a block, so you could as well write the code above as: > > require 'net/http' > require 'uri' > 10.times do > Thread.new do > Net::HTTP.get_response(URI.parse('http://www.google.com/')) > end > end > > maybe this is a bit more clear to you? Thanks, I saw that the first curly brace need to be on the same line of Thread.new. I've tested the code above, but it seems that it doesn't work like I thought because on the web server and application server logs I saw only one request when I run the code (of course with the correct address), maybe my statement isn't clear: I need to call a URL multiple time, like if I press F5 on the browser...I've found a way using Watir example, but without it would be better so I can use the script on any platform. Thanks. Best regards. -- Posted via http://www.ruby-forum.com/.