From e8ced3d13c61bb3278c7c2b2ae4167fb3f1ae242 Mon Sep 17 00:00:00 2001 From: Grzegorz Grasza Date: Tue, 13 Nov 2018 11:51:41 +0100 Subject: [PATCH] Reconnect on httplib.ResponseNotReady In CI we get a random ResponseNotReady exception, which is caused by the server closing the keepalive socket. This will close and retry the connection. Change-Id: I28e51450cbfea8bf7a18e5783355b68f806eb999 --- novajoin/ipa.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/novajoin/ipa.py b/novajoin/ipa.py index 42ae81c..f5f2497 100644 --- a/novajoin/ipa.py +++ b/novajoin/ipa.py @@ -17,6 +17,9 @@ import os import time import uuid +from six.moves import http_client + + try: from gssapi.exceptions import GSSError from ipalib import api @@ -161,6 +164,13 @@ class IPANovaJoinBase(object): tries += 1 if self.backoff: self.__backoff() + except http_client.ResponseNotReady: + # NOTE(xek): This means that the server closed the socket, + # so keep-alive ended and we can't use that connection. + api.Backend.rpcclient.disconnect() + tries += 1 + if self.backoff: + self.__backoff() else: return