reuse connection

This commit is contained in:
Conor Stevenson 2020-06-02 08:45:59 +01:00 committed by Asif Saif Uddin
parent 255b85229b
commit ff7c1e3041
2 changed files with 5 additions and 1 deletions

View File

@ -434,7 +434,7 @@ class Connection(object):
if not reraise_as_library_errors:
ctx = self._dummy_context
with ctx():
self._connection = retry_over_time(
self._connection = self._connection or retry_over_time(
self._connection_factory, self.recoverable_connection_errors,
(), {}, on_error, max_retries,
interval_start, interval_step, interval_max,

View File

@ -144,6 +144,10 @@ class test_Connection:
assert not _connection.connected
assert isinstance(conn.transport, Transport)
def test_reuse_connection(self):
conn = self.conn
assert conn.connect() is conn.connection is conn.connect()
def test_connect_no_transport_options(self):
conn = self.conn
conn._ensure_connection = Mock()