Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6685743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:05:32+00:00 2026-05-26T05:05:32+00:00

Little question about Ruby error handling. I have some code that roughly resembles the

  • 0

Little question about Ruby error handling. I have some code that roughly resembles the following:

urls.each do |url|
begin
  threads << 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 }

However, when I run this I occasionally come across URLs that redirect, producing the following error:

/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'

with the two last lines referring to the line of code containing the threads.each block.

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T05:05:33+00:00Added an answer on May 26, 2026 at 5:05 am

    Never mind, silly mistake. I put the begin..rescue block inside the Thread.do block and it worked.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a little question about how to implement some sort of graphics editor.
I have little question about how web browser retrieve webpage? I know this User
A small - little question. I have seen many application having buttons like following.
I have this little question that's been on my mind for a while now.
I have a dedicated server that hosts about 70 domains... some are just plain
I have little knowledge about SQL queries and I am new to ruby on
I have a little question about my URL . I use a tree view
Quick little question... I know that sometimes in other languages libraries have part of
Quick question about Ruby forking - I ran across a bit of forking code
I asked a little while ago a question about rollback, I have a new

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.