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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T00:16:11+00:00 2026-06-17T00:16:11+00:00

Here is my ugly little code snippet now: for i in range(5): try: self.startTime=time.time()

  • 0

Here is my ugly little code snippet now:

for i in range(5):
        try:
            self.startTime=time.time()
            self.rawfeed=requests.get(self.feedurl)
            continue
        except ConnectionError:
            print "Got a connection error.  Retrying", i
            time.sleep(i*i) # giving a bit longer wait each time
            pass
if i == 5: raise
self.ResponseTime=time.time()-self.startTime

Two problems here. First my except statement does not seem to recognize “ConnectionError” as an exception (SOLVED, thanks, stackers), but rather complains that it isn’t a global variable. And second, and more important, I would really like to know if the error is MY side, or the SERVER’s side.

Typically I want to retry on MY errors, but give up and report on a SERVER error. (By “MY” error, I mean anything other than a server error.)

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

    Taking a look at the requests source code, ConnectionError is only raised if it retries the maximum amount of times (MaxRetryError).

    except MaxRetryError, e:
        if not self.config.get('safe_mode', False):
            raise ConnectionError(e)
    

    It’s quite impossible to say whether or not this is caused by your side or the server, as so many issues on both sides could cause this exact same error. For example, if the server’s HTTP daemon is not running, your connection attempts will time out. The exact same thing will happen if you block them in your router or if your router drops the connection for some other reason.

    Exception HTTPError, though, which you are not catching, is much more likely to be a server error that you can die on. ConnectionError is somewhat likely, but not at all guaranteed, to be yourself.

    Your second issue is that you are not properly importing these classes. Either change your except to except requests.ConnectionError, or do from requests import ConnectionError, HTTPError.

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

Sidebar

Related Questions

I have one little problem...Here is my code..Is there a way to distribute weights
I'm making a little game, here is some example code of whats going on:
I try to code a little Picture Puzzle for a family party in some
Here is what I mean: I need to be able to substitute this ugly
Here's my code in the <head></head> : <link rel=stylesheet href=http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.css /> <script type=text/javascript src=http://code.jquery.com/jquery-1.7.1.min.js></script>
Here is the code in a function I'm trying to revise. This example works
Here is the code: create table `team`.`User`( `UserID` bigint NOT NULL AUTO_INCREMENT , `Username`
well, the title pretty much says it all. here's a little info: i have
Just found a bit of code someone here had written to access some DB
I have this code: def GetSteamAccts(): #Get list of steam logins on this computer.

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.