From 3a8225889147f8ce1e4feeb65a7860b6f4a37576 Mon Sep 17 00:00:00 2001 From: Narayan Desai Date: Tue, 25 Oct 2005 09:47:13 +0000 Subject: add retries (Logical change 1.347) git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@1440 ce84e21b-d406-0410-9b95-82705330c041 --- src/lib/Client/XMLRPCComm.py | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/lib/Client/XMLRPCComm.py b/src/lib/Client/XMLRPCComm.py index 3485e7fc2..bc230e4dd 100644 --- a/src/lib/Client/XMLRPCComm.py +++ b/src/lib/Client/XMLRPCComm.py @@ -1,10 +1,12 @@ '''XMLRPC/SSL Communication Library (following the ssslib API)''' __revision__ = '$Revision:$' -from elementtree.ElementTree import XML, tostring +from elementtree.ElementTree import XML from ConfigParser import ConfigParser from M2Crypto.m2xmlrpclib import ServerProxy, SSL_Transport from xmlrpclib import Fault +from sys import exc_info +from traceback import extract_tb class CommunicationError(Exception): '''Duplicate the sss.ssslib error API''' @@ -43,10 +45,21 @@ class comm_lib(object): print "unsupported function call" raise CommunicationError, "foo" func = getattr(self.proxy, funcname) - try: - self.response = apply(func, args) - except Fault, msg: - raise CommunicationError, msg + for i in range(5): + try: + self.response = apply(func, args) + return + except Fault, msg: + raise CommunicationError, msg + except: + continue + (trace, val, trb) = exc_info() + print "Unexpected communication error after retry" + for line in extract_tb(trb): + print ' File "%s", line %i, in %s\n %s\n' % line + print "%s: %s\n" % (trace, val) + del trace, val, trb + raise CommunicationError, "no connect" def RecvMessage(self, handle): '''Return cached response''' -- cgit v1.2.3-1-g7c22