WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] When we see a httplib.BadStatusLine, sleep 5 seconds and

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] When we see a httplib.BadStatusLine, sleep 5 seconds and then retry. This
From: Xen patchbot -unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Tue, 13 Dec 2005 19:38:12 +0000
Delivery-date: Tue, 13 Dec 2005 19:40:30 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User emellor@xxxxxxxxxxxxxxxxxxxxxx
# Node ID d37644abe52d0d10d54ab55157677f8612e4778e
# Parent  95f84e37c90d573dd01cc29db5b81ffb5f86f84a
When we see a httplib.BadStatusLine, sleep 5 seconds and then retry.  This
happens when Xend crashes, so retrying once allows it to restart and recover.
If we see Xend crash twice, we give up, but throw a more polite exception than
the BadStatusLine splat that we got previously.

Signed-off-by: Ewan Mellor <ewan@xxxxxxxxxxxxx>

diff -r 95f84e37c90d -r d37644abe52d tools/python/xen/xend/XendProtocol.py
--- a/tools/python/xen/xend/XendProtocol.py     Tue Dec 13 18:06:03 2005
+++ b/tools/python/xen/xend/XendProtocol.py     Tue Dec 13 18:07:51 2005
@@ -13,10 +13,12 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #============================================================================
 # Copyright (C) 2004, 2005 Mike Wray <mike.wray@xxxxxx>
+# Copyright (C) 2005 XenSource Ltd.
 #============================================================================
 
 import socket
 import httplib
+import time
 import types
 
 from encode import *
@@ -165,23 +167,37 @@
         @param method: http method: POST or GET
         @param args:   request arguments (dict)
         """
-        self.request = self.makeRequest(url, method, args)
-        conn = self.makeConnection(url)
-        if DEBUG: conn.set_debuglevel(1)
-        conn.request(method, url.fullpath(), self.request.data, 
self.request.headers)
-        resp = conn.getresponse()
-        self.resp = resp
-        val = self.handleStatus(resp.version, resp.status, resp.reason)
-        if val is None:
-            data = None
-        else:
-            data = resp.read()
-        conn.close()
-        val = self.handleResponse(data)
-        return val
+        retries = 0
+        while retries < 2:
+            self.request = self.makeRequest(url, method, args)
+            conn = self.makeConnection(url)
+            try:
+                if DEBUG: conn.set_debuglevel(1)
+                conn.request(method, url.fullpath(), self.request.data,
+                             self.request.headers)
+                try:
+                    resp = conn.getresponse()
+                    self.resp = resp
+                    val = self.handleStatus(resp.version, resp.status,
+                                            resp.reason)
+                    if val is None:
+                        data = None
+                    else:
+                        data = resp.read()
+                    val = self.handleResponse(data)
+                    return val
+                except httplib.BadStatusLine:
+                    retries += 1
+                    time.sleep(5)
+            finally:
+                conn.close()
+
+        raise XendError("Received invalid response from Xend, twice.")
+
 
     def getHeader(self, key):
         return self.resp.getheader(key)
+
 
 class UnixConnection(httplib.HTTPConnection):
     """Subclass of Python library HTTPConnection that uses a unix-domain 
socket.

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] When we see a httplib.BadStatusLine, sleep 5 seconds and then retry. This, Xen patchbot -unstable <=