Skip to content

connection stops being reused after error hit #16

Open

Description

@ellieayla

The function xmlclient.py:SoapEnvelope.post() is called with conn as an instance of a httplib.HTTPSConnection produced by makeConnection().

The "conn" variable is, however, sometimes recreated inside here with conn = makeConnection(scheme, host). This doesn't make much sense for recovery, since it will never be propagated back up to the caller's __conn. The only valid use-case is when the caller didn't pass a connection (which does happen in Client.login() until Client.useSession() is called immediately after.

But if an exception is thrown, this sets conn=None and then makes a new local conn on the next pass.

         except (httplib.HTTPException, socket.error):
            if conn != None:
                conn.close()
                conn = None
                response = None

I think this reconnect loop was born of frustration without thinking things through.

It probably makes more sense to never set conn = None, and just do a conn.close(). The next iteration's conn.request() will cause a new open, if required, since conn.auto_open=True.

Activity

  1. ellieayla commented on Dec 8, 2014

    @ellieayla
    ContributorAuthor

    I made that change locally and left a session up for 3 days doing this; no problems experienced.

    while True:
       time.sleep(120)
       print svc.describeTabs()[0]['label']
    
  2. idbentley commented on Feb 2, 2015

    @idbentley

    Sorry about my negligence, I was afk for the past 2 months. I will address these prs in the following week.

  3. idbentley commented on Feb 5, 2015

    @idbentley

    There are significant problems with the way the initial connection is set up. This is definitely one of them. If you submit a pull request with a proposed alternative, there is lots of room for improvement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions