[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Brad Tilley

10/25/2006 2:38:00 AM

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

--
Posted via http://www.ruby-....

7 Answers

Michael Fellinger

10/25/2006 6:26:00 AM

0

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.cabo...

^ manveru

Brad Tilley

10/25/2006 12:00:00 PM

0

Michael Fellinger wrote:
> i made a small example here:
> http://pastie.cabo...
>
> ^ manveru

Thank you for the example!


--
Posted via http://www.ruby-....

Brad Tilley

10/26/2006 1:11:00 AM

0

What are reasonable limits on threads? Say I'm scanning a class b
network (roughly 65K hosts). How would you break up the threads? I seem
to get too many execution expired errors if I have more than 500 hosts
in one thread. It seems to work best with 256 groups of 256 hosts each
or 254 if you exclude the 0's and 255's

What are reasonable limits when working with threads in Ruby? Any tips?


--
Posted via http://www.ruby-....

Michael Fellinger

10/26/2006 2:41:00 AM

0

On Thursday 26 October 2006 10:10, Brad Tilley wrote:
> What are reasonable limits on threads? Say I'm scanning a class b
> network (roughly 65K hosts). How would you break up the threads? I seem
> to get too many execution expired errors if I have more than 500 hosts
> in one thread. It seems to work best with 256 groups of 256 hosts each
> or 254 if you exclude the 0's and 255's
>
> What are reasonable limits when working with threads in Ruby? Any tips?

No tips there... it always depends on the task on hand - just use what works
for you :)

Farrel Lifson

10/26/2006 7:54:00 AM

0

On 26/10/06, Michael Fellinger <m.fellinger@gmail.com> wrote:
> On Thursday 26 October 2006 10:10, Brad Tilley wrote:
> > What are reasonable limits on threads? Say I'm scanning a class b
> > network (roughly 65K hosts). How would you break up the threads? I seem
> > to get too many execution expired errors if I have more than 500 hosts
> > in one thread. It seems to work best with 256 groups of 256 hosts each
> > or 254 if you exclude the 0's and 255's
> >
> > What are reasonable limits when working with threads in Ruby? Any tips?
>
> No tips there... it always depends on the task on hand - just use what works
> for you :)
>
>

You might try using a MapReduce/DRb based approach instead of threads.
Have a look at Starfish (http://rufy.com/sta...) for ideas.

Farrel

Ara.T.Howard

10/26/2006 8:26:00 PM

0

Ara.T.Howard

10/26/2006 10:27:00 PM

0