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 8596817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:46:13+00:00 2026-06-12T00:46:13+00:00

This error pops up randomly, and I’m pretty sure it’s because the infoGotten variable

  • 0

This error pops up randomly, and I’m pretty sure it’s because the infoGotten variable isn’t initialized before the return statement calls it. The part that has me puzzled is how it’s getting to that part of the code to produce that error in the first place. Hopefully someone can explain to me why that is as I haven’t been able to figure it out yet. I’m guessing it’s because of the try/except statement but I did some searching and checked 7.4 in the manual and it doesn’t appear (to me anyways) that I’m doing something incorrect.

breakLoop = 0
def get_item_info(linkParameters):
    global breakLoop
    nheaders = {'User-Agent' : 'Firefox/15.0.1'}
    purl = 'http://example.com/something.php'
    pd = linkParameters
    nreq = urllib.request.Request(purl, pd, nheaders)
    if breakLoop >= 4:
        return 'Request timed out {} times'.format(breakLoop)
    try:
        nresponse = urllib.request.urlopen(nreq)
    except urllib.error.URLError:
        breakLoop += 1
        get_item_info(pd)
    except urllib.error.HTTPError:
        breakLoop += 1
        get_item_info(pd)        
    else:
        infoGotten = nresponse.read()
    return infoGotten

Thanks!

  • 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-06-12T00:46:14+00:00Added an answer on June 12, 2026 at 12:46 am

    You need to return the results of the recursive calls, so it should be return get_item_info(pd) in the except clauses (which I combined below):

    breakLoop = 0
    def get_item_info(linkParameters):
        nheaders = {'User-Agent' : 'Firefox/15.0.1'}
        purl = 'http://example.com/something.php'
        pd = linkParameters
        nreq = urllib.request.Request(purl, pd, nheaders)
        if breakLoop >= 4:
            return 'Request timed out {} times'.format(breakLoop)
        try:
            nresponse = urllib.request.urlopen(nreq)
        except (urllib.error.URLError, urllib.error.HTTPError):
            breakLoop += 1
            return get_item_info(pd)
        else:   
            return nresponse.read()
    

    Recursion seems like a weird way to perform the retries though, why not use a loop? The following seems more clear:

    def get_item_info(linkParameters):
        nheaders = {'User-Agent' : 'Firefox/15.0.1'}
        purl = 'http://example.com/something.php'
        pd = linkParameters
        for i in range(5):
            nreq = urllib.request.Request(purl, pd, nheaders)
            try:
                nresponse = urllib.request.urlopen(nreq)
                return nresponse.read()
            except (urllib.error.URLError, urllib.error.HTTPError):
                pass
        return 'Request timed out 4 times'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing this JS for CRM 2011, and this error pops out whenever
Everytime I run the program, this mysterious error pops up saying that I have
This error is driving me crazy . I tried freenode #emberjs before asking here.
Works fine on the local machine, but when deployed this error message pops up:
I tried submitting this and an error pops up saying ** END OF FILE
This error has been bugging me on and off for months: Printing failed because
This error is driving me crazy. I'm developing an App Engine Python application. These
This error come in log. from='kutbi1@360degree/Smack' to='akash@360degree/Smack' type='error' id='hK1L6-5'> <si xmlns='http://jabber.org/protocol/si' id='jsi_191216212994140179' mime-type='image/png' profile='http://jabber.org/protocol/si/profile/file-transfer'>
this error is always fired, when i'm try to free my allocated struct the
This code gives me this error:Cannot implicitly convert type ArrayList[] to ArrayList[][] at this

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.