diff options
-rw-r--r-- | kombu/connection.py | 2 | ||||
-rw-r--r-- | t/unit/test_connection.py | 10 |
2 files changed, 11 insertions, 1 deletions
diff --git a/kombu/connection.py b/kombu/connection.py index a63154f5..e4558e92 100644 --- a/kombu/connection.py +++ b/kombu/connection.py @@ -837,7 +837,7 @@ class Connection: return self.transport.qos_semantics_matches_spec(self.connection) def _extract_failover_opts(self): - conn_opts = {} + conn_opts = {'timeout': self.connect_timeout} transport_opts = self.transport_options if transport_opts: if 'max_retries' in transport_opts: diff --git a/t/unit/test_connection.py b/t/unit/test_connection.py index 0b184d3b..83f233cf 100644 --- a/t/unit/test_connection.py +++ b/t/unit/test_connection.py @@ -587,6 +587,16 @@ class test_Connection: conn = Connection('example.com;example.com;') assert conn.as_uri() == 'amqp://guest:**@example.com:5672//' + def test_connection_respect_its_timeout(self): + invalid_port = 1222 + with Connection( + f'amqp://guest:guest@localhost:{invalid_port}//', + transport_options={'max_retries': 2}, + connect_timeout=1 + ) as conn: + with pytest.raises(OperationalError): + conn.default_channel + class test_Connection_with_transport_options: |