6705438
From 255b85229b7395b7424a26eac0ab79fb813d596e Mon Sep 17 00:00:00 2001
6705438
From: Conor Stevenson <c.stevenson@outlook.com>
6705438
Date: Mon, 1 Jun 2020 22:23:05 +0100
6705438
Subject: [PATCH] set _connection in _ensure_connection (#1205)
6705438
6705438
Co-authored-by: Conor Stevenson <conor@lendingblock.com>
6705438
---
6705438
 kombu/connection.py       | 5 +++--
6705438
 t/unit/test_connection.py | 2 ++
6705438
 2 files changed, 5 insertions(+), 2 deletions(-)
6705438
6705438
diff --git a/kombu/connection.py b/kombu/connection.py
6705438
index 989a58682..5922c0187 100644
6705438
--- a/kombu/connection.py
6705438
+++ b/kombu/connection.py
6705438
@@ -434,12 +434,13 @@ def on_error(exc, intervals, retries, interval=0):
6705438
         if not reraise_as_library_errors:
6705438
             ctx = self._dummy_context
6705438
         with ctx():
6705438
-            return retry_over_time(
6705438
+            self._connection = retry_over_time(
6705438
                 self._connection_factory, self.recoverable_connection_errors,
6705438
                 (), {}, on_error, max_retries,
6705438
                 interval_start, interval_step, interval_max,
6705438
                 callback, timeout=timeout
6705438
             )
6705438
+            return self._connection
6705438
 
6705438
     @contextmanager
6705438
     def _reraise_as_library_errors(
6705438
@@ -860,7 +861,7 @@ def connection(self):
6705438
         if not self._closed:
6705438
             if not self.connected:
6705438
                 conn_opts = self._extract_failover_opts()
6705438
-                self._connection = self._ensure_connection(**conn_opts)
6705438
+                self._ensure_connection(**conn_opts)
6705438
             return self._connection
6705438
 
6705438
     def _connection_factory(self):
6705438
diff --git a/t/unit/test_connection.py b/t/unit/test_connection.py
6705438
index 017dfae49..8a39855c6 100644
6705438
--- a/t/unit/test_connection.py
6705438
+++ b/t/unit/test_connection.py
6705438
@@ -131,7 +131,9 @@ def setup(self):
6705438
 
6705438
     def test_establish_connection(self):
6705438
         conn = self.conn
6705438
+        assert not conn.connected
6705438
         conn.connect()
6705438
+        assert conn.connected
6705438
         assert conn.connection.connected
6705438
         assert conn.host == 'localhost:5672'
6705438
         channel = conn.channel()