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

  • Home
  • SEARCH
  • 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 8911501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:57:39+00:00 2026-06-15T03:57:39+00:00

I recently inherited a python project, and I’m working on maintaining it now. Part

  • 0

I recently inherited a python project, and I’m working on maintaining it now. Part of the code makes a few hundred thousand requests from a website and saves the results to a database. The code is reusing the same httplib.HTTPConnection object for reach request and then just looping over a

conn.request("GET",someString,'',headers)

response = conn.getresponse()

section. A few days ago in my logs I saw that one of the requests threw the exception:

[Errno 104] Connection reset by peer  

followed by every other conn.request() failing. My first inclination was to just build a new connection for each request, but the perfomance impact of that was profound and horrible. So my question is, how do I fix this, especially since I’m not 100% sure how I can even really test this.

If I just call conn.connect() after an exception, will it correctly reconnect?

I’m looking for advise on how to fix it and possibly how I could test it.

Thanks for your time.

  • 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-15T03:57:40+00:00Added an answer on June 15, 2026 at 3:57 am

    I think you first need to decide the failure mode you want to handle. For instance, did the connection reset because of a temporary resource problem on the server and a quick turnaround connect will fix it? Or, is the server down or rebooting and you should abort your process?

    Presuming the first case, I think you are thinking along the right lines. Try something like this (note, this is not working code – it’s just an example of the logic):

    while True:
        try:
            conn.request("GET",someString,'',headers)
            response = conn.getresponse()
        except httplib.HTTPException, e:
            conn.connect()
            continue
        break
    

    You should probably add some logic to that to pause between repeated connect attempts and to give up after a certain number of tries (which is basically the second scenario above).

    In order to test this, try using tcpkill to cause the TCP connection to reset:

    http://www.gnutoolbox.com/tcpkill-command/

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

Sidebar

Related Questions

I recently inherited a project that is using Spring SAML 2.0 but the code
I recently inherited a project where a sqlite db is stored on the users
I've recently inherited a web project from a workmate who left to join another
I recently inherited a large software project written in Java. The last developer used
I've recently inherited a project for the iPad which is basically an image/presentation viewer.
I recently inherited some code that is having occasional time-out issues. I am mostly
Our team has recently inherited code which is extremely disorganized. As a result, my
I’m looking for some advice. I recently wrapped up a project where I inherited
I have recently inherited a large project using an sqlite3 database and currently I
In some code that I've recently inherited the responsibility for, I've found several instances

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.