diff options
author | Hervé Beraud <hberaud@redhat.com> | 2020-06-18 13:04:17 +0200 |
---|---|---|
committer | Hervé Beraud <hberaud@redhat.com> | 2020-06-18 13:25:24 +0200 |
commit | 661bdd7f41d1e253e76c9d516019eb6aafe90f15 (patch) | |
tree | a2e79181c5cea29425c6dcb7969e52363ac73bf1 | |
parent | c2074e47604199e9802520dbc4dfb54da778e090 (diff) | |
download | oslo-messaging-661bdd7f41d1e253e76c9d516019eb6aafe90f15.tar.gz |
Drop a python 2 exception management
Previously (when python 2 was supported) we introduced some specific
exception management to detect connections issues when a rabbitmq
cluster node disappearing.
The original issue was that a ConnectionRefusedError is thrown and not
managed by oslo.messaging to detect heartbeat issue and call ensure_connection
for switching the connection destination (cluster node).
`ConnectionRefusedError` is only a python 3 exception [2].
Now that we only support python 3 we don't need to continue to
wrap/emulate this kind of exceptions (ConnectionRefusedError) [2] and
so we can drop the python 2 compatibility code to only support python 3 code.
[1] https://github.com/openstack/oslo.messaging/commit/9d8b1430e5c081b081c0e3c0b5f12f744dc7809d
[2] https://docs.python.org/3/library/exceptions.html#ConnectionRefusedError
Change-Id: I4c459d8c947dac213a1866c0d37e8f3d547aa82e
-rw-r--r-- | oslo_messaging/_drivers/impl_rabbit.py | 9 |
1 files changed, 1 insertions, 8 deletions
diff --git a/oslo_messaging/_drivers/impl_rabbit.py b/oslo_messaging/_drivers/impl_rabbit.py index c5c3970..f6ddf8f 100644 --- a/oslo_messaging/_drivers/impl_rabbit.py +++ b/oslo_messaging/_drivers/impl_rabbit.py @@ -975,13 +975,6 @@ class Connection(object): def _heartbeat_thread_job(self): """Thread that maintains inactive connections """ - # NOTE(hberaud): Python2 doesn't have ConnectionRefusedError - # defined so to switch connections destination on failure - # with python2 and python3 we need to wrapp adapt connection refused - try: - ConnectRefuseError = ConnectionRefusedError - except NameError: - ConnectRefuseError = socket.error while not self._heartbeat_exit_event.is_set(): with self._connection_lock.for_heartbeat(): @@ -1008,7 +1001,7 @@ class Connection(object): # ensure_connection for switching the # connection destination. except (socket.timeout, - ConnectRefuseError, + ConnectionRefusedError, OSError, kombu.exceptions.OperationalError) as exc: LOG.info("A recoverable connection/channel error " |