title: Ruby open-uri RuntimeError - redirection forbidden
body: <p>Little question about Ruby error handling. I have some code that roughly resembles the following:</p>
  
  <pre><code>urls.each do |url|
  begin
    threads &lt;&lt; Thread.new(url) do |url|
      page = open(url)
      # some further processing of page
    end
  rescue
    puts "Could not retrieve url"
  end
  threads.each { |thread| thread.join }
  </code></pre>
  
  <p>However, when I run this I occasionally come across URLs that redirect, producing the following error:</p>
  
  <pre><code>/usr/lib/ruby/1.8/open-uri.rb:174:in `open_loop': redirection forbidden: // url goes here
  from my_file.rb in 'join'
  from my_file.rb in 'each'
  </code></pre>
  
  <p>with the two last lines referring to the line of code containing the threads.each block.</p>
  
  <p>I was just wondering why I am getting this error considering I have a begin-rescue block in place? Is there something subtle I'm missing here, perhaps to do with the multithreading?</p>