On Thu, Nov 19, 2009 at 6:34 AM, jhaagmans <jaap.haagm...@gmail.com> wrote:
> Hi Fred, > > On 19 nov, 14:59, Frederick Cheung <frederick.che...@gmail.com> wrote: > > On Nov 19, 1:22 pm, jhaagmans <jaap.haagm...@gmail.com> wrote:> Hi Fred, > > > > > Thanks for your response. I hope you can answer three questions about > > > this. > > > > > - Why is it that pharrington's example did work, even though the hosts > > > he used (I copied them) were never resolved before on my server? I > > > should have had the same problem, right? > > > > maybe, maybe not - not sure what varies between different dns lookups. > > Me neither. That's why I was wondering. > > > > > > - I've used net-dns before because what I really want to do is check a > > > domain for existence in the DNS-records of a certain server. However, > > > the problem with this is that because of the TTL, when I query a > > > domain every hour, a domain that has been deleted from the DNS doesn't > > > really get deleted from the "visible" records for 4 - 24 hours. That's > > > something I really need to work around, do you have an idea how I can > > > get that to work? > > > > Are you really working around it by using net/http ? > > Good point. The answer is no. I thought I'd work around it because > with a full HTTP-request you'd not only query the DNS, you'd also > query the webserver, but if someone doesn't actually delete the files > from the server, you'd still get a 200-response. > > Now I need to work around that as well and I doubt it's possible as we > don't actually control the DNS servers we use. I can't think of a > workaround for this. > > > > > > > > > > - Why is it that most of the logged messages are 10 seconds apart? > > > That should tell me something, but I'm unsure what. > > > > Is this still inside backgroundrb or have you managed to reproduce > > this outside background rb ? > > You're right, it's still inside backgroundrb. However, I ran > pharrington's example from BRB as well. > > @Conrad: > > [j...@server06 ~]$ ruby -v > ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-linux], MBARI 0x8770, > Ruby Enterprise Edition 20090928 > > And yes, I'm still using BRB, I really can't think of a way to avoid > using BRB. I need to query a few thousand hosts every hour, every day. > > I really regret choosing Ruby/Rails for this particular application at > this point. > Jaap, please tell if the following works for you: require 'net/http' module Enumerable def concurrently map{ |item| Thread.new { yield item }}.each{ |t| t.join } end end def hosts %w[rubyforge.org www.scala-lang.org www.google.com www.gamefaqs.com allrecipes.com m2k2.taigaforum.com youtube.com gitorious.org everything2.com] end hosts.concurrently do |host| begin puts "\nfetching host #{host} - #{Time.now}\n" client = Net::HTTP.start(host) rescue e #store host as inactive ensure puts "\nfinished with host #{host} - #{Time.now}\n" client.finish if client.active? end end -Conrad > > -- > > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-t...@googlegroups.com. > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscr...@googlegroups.com<rubyonrails-talk%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=. > > > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=.