diff options
author | Narayan Desai <desai@mcs.anl.gov> | 2005-10-25 09:47:13 +0000 |
---|---|---|
committer | Narayan Desai <desai@mcs.anl.gov> | 2005-10-25 09:47:13 +0000 |
commit | 3a8225889147f8ce1e4feeb65a7860b6f4a37576 (patch) | |
tree | 12f71e950c7b9e07c20eed236472835194240d8e /src/lib | |
parent | 87ba1d48f3578b5511db5062f748c8ca841469ac (diff) | |
download | bcfg2-3a8225889147f8ce1e4feeb65a7860b6f4a37576.tar.gz bcfg2-3a8225889147f8ce1e4feeb65a7860b6f4a37576.tar.bz2 bcfg2-3a8225889147f8ce1e4feeb65a7860b6f4a37576.zip |
add retries
(Logical change 1.347)
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@1440 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/Client/XMLRPCComm.py | 23 |
1 files 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''' |