Skip to content

Commit

Permalink
set _connection in _ensure_connection (#1205)
Browse files Browse the repository at this point in the history
Co-authored-by: Conor Stevenson <conor@lendingblock.com>
  • Loading branch information
ConorStevenson and Conor Stevenson committed Jun 1, 2020
1 parent 1be72e3 commit 255b852
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 3 additions & 2 deletions kombu/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,12 +434,13 @@ def on_error(exc, intervals, retries, interval=0):
if not reraise_as_library_errors:
ctx = self._dummy_context
with ctx():
return retry_over_time(
self._connection = retry_over_time(
self._connection_factory, self.recoverable_connection_errors,
(), {}, on_error, max_retries,
interval_start, interval_step, interval_max,
callback, timeout=timeout
)
return self._connection

@contextmanager
def _reraise_as_library_errors(
Expand Down Expand Up @@ -860,7 +861,7 @@ def connection(self):
if not self._closed:
if not self.connected:
conn_opts = self._extract_failover_opts()
self._connection = self._ensure_connection(**conn_opts)
self._ensure_connection(**conn_opts)
return self._connection

def _connection_factory(self):
Expand Down
2 changes: 2 additions & 0 deletions t/unit/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ def setup(self):

def test_establish_connection(self):
conn = self.conn
assert not conn.connected
conn.connect()
assert conn.connected
assert conn.connection.connected
assert conn.host == 'localhost:5672'
channel = conn.channel()
Expand Down

0 comments on commit 255b852

Please sign in to comment.