mirror of https://github.com/celery/kombu.git
respect connection timeout (#1458)
* pass timeout to ensure connection function * test connection respect its timeout
This commit is contained in:
parent
47781af050
commit
a9c4f9837c
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
|
||||
|
|
Loading…
Reference in New Issue