ansible: gracefully report connection timeouts as StreamError.

pull/244/head
David Wilson 7 years ago
parent c0e8b3d60a
commit 8bd34e1e28

@ -356,7 +356,8 @@ class Connection(ansible.plugins.connection.ConnectionBase):
executing. We use the opportunity to grab relevant bits from the
task-specific data.
"""
self.ansible_ssh_timeout = task_vars.get('ansible_ssh_timeout')
self.ansible_ssh_timeout = task_vars.get('ansible_ssh_timeout',
C.DEFAULT_TIMEOUT)
self.python_path = task_vars.get('ansible_python_interpreter',
'/usr/bin/python')
self.mitogen_via = task_vars.get('mitogen_via')

@ -974,6 +974,8 @@ class Router(mitogen.core.Router):
self._context_by_id[context_id] = context
return context
connection_timeout_msg = "Connection timed out."
def _connect(self, klass, name=None, **kwargs):
context_id = self.allocate_id()
context = self.context_class(self, context_id)
@ -982,7 +984,11 @@ class Router(mitogen.core.Router):
stream = klass(self, context_id, **kwargs)
if name is not None:
stream.name = name
stream.connect()
try:
stream.connect()
except mitogen.core.TimeoutError:
e = sys.exc_info()[1]
raise mitogen.core.StreamError(self.connection_timeout_msg)
context.name = stream.name
self.route_monitor.notice_stream(stream)
self.register(context, stream)

Loading…
Cancel
Save