From: Michael Fellinger Date: 2006-10-25T15:25:57+09:00 Subject: Re: threads On Wednesday 25 October 2006 11:37, Brad Tilley wrote: > I'm rewriting some old Python scripts in Ruby. Just to learn a bit more. > I want to thread this code to check websites concurrently. Could somone > offer advice? What are reasonable limits on threads in Ruby? > > ips.each do |ip| > begin > Timeout::timeout(5) do > Net::HTTP.start(ip) do |site| > data = site.get( '/' ).body.downcase > if data.include?(minolta) and > data.include?(pagescope) > puts printer + "\t" + ip > elsif data.include?(xerox) and > data.include?(printer) > puts printer + "\t" + ip > else > puts "website\t" + ip > end > end > end > # Don't really care about exceptions just time outs mostly. > rescue Timeout::Error > puts "Timeout\t" + ip > rescue Exception > puts "General Exception\t" + ip > end > end i made a small example here: http://pastie.caboo.se/19495 ^ manveru