Fix try/except syntax for Python 3

"except (IOError, errors):" fails with a TypeError if errors is a tuple on
Python 3, whereas it was accepted in Python 2.

Change-Id: I65cfb60af87e76fdf2d37043fb106adbd4586fb9
This commit is contained in:
Victor Stinner 2013-12-18 17:18:55 +01:00
parent 64f91d30a8
commit 43e9d5fef5

@ -530,7 +530,9 @@ class Connection(object):
try:
self._connect(params)
return
except (IOError, self.connection_errors) as e:
except IOError:
pass
except self.connection_errors:
pass
except Exception as e:
# NOTE(comstud): Unfortunately it's possible for amqplib
@ -571,7 +573,10 @@ class Connection(object):
while True:
try:
return method(*args, **kwargs)
except (self.connection_errors, socket.timeout, IOError) as e:
except self.connection_errors as e:
if error_callback:
error_callback(e)
except (socket.timeout, IOError) as e:
if error_callback:
error_callback(e)
except Exception as e: