|
|
|
@ -370,8 +370,11 @@ class Connection(NetworkConnectionBase):
|
|
|
|
|
command_prompt_matched = False
|
|
|
|
|
matched_prompt_window = window_count = 0
|
|
|
|
|
|
|
|
|
|
cache_socket_timeout = self._ssh_shell.gettimeout()
|
|
|
|
|
command_timeout = self.get_option('persistent_command_timeout')
|
|
|
|
|
self._validate_timeout_value(command_timeout, "persistent_command_timeout")
|
|
|
|
|
if cache_socket_timeout != command_timeout:
|
|
|
|
|
self._ssh_shell.settimeout(command_timeout)
|
|
|
|
|
|
|
|
|
|
buffer_read_timeout = self.get_option('persistent_buffer_read_timeout')
|
|
|
|
|
self._validate_timeout_value(buffer_read_timeout, "persistent_buffer_read_timeout")
|
|
|
|
@ -393,6 +396,8 @@ class Connection(NetworkConnectionBase):
|
|
|
|
|
signal.alarm(command_timeout)
|
|
|
|
|
|
|
|
|
|
except AnsibleCmdRespRecv:
|
|
|
|
|
# reset socket timeout to global timeout
|
|
|
|
|
self._ssh_shell.settimeout(cache_socket_timeout)
|
|
|
|
|
return self._command_response
|
|
|
|
|
else:
|
|
|
|
|
data = self._ssh_shell.recv(256)
|
|
|
|
@ -423,6 +428,8 @@ class Connection(NetworkConnectionBase):
|
|
|
|
|
resp = self._strip(self._last_response)
|
|
|
|
|
self._command_response = self._sanitize(resp, command)
|
|
|
|
|
if buffer_read_timeout == 0.0:
|
|
|
|
|
# reset socket timeout to global timeout
|
|
|
|
|
self._ssh_shell.settimeout(cache_socket_timeout)
|
|
|
|
|
return self._command_response
|
|
|
|
|
else:
|
|
|
|
|
command_prompt_matched = True
|
|
|
|
@ -445,7 +452,8 @@ class Connection(NetworkConnectionBase):
|
|
|
|
|
return to_text(response, errors='surrogate_or_strict')
|
|
|
|
|
except (socket.timeout, AttributeError):
|
|
|
|
|
display.vvvv(traceback.format_exc(), host=self._play_context.remote_addr)
|
|
|
|
|
raise AnsibleConnectionFailure("timeout trying to send command: %s" % command.strip())
|
|
|
|
|
raise AnsibleConnectionFailure("timeout value %s seconds reached while trying to send command: %s"
|
|
|
|
|
% (self._ssh_shell.gettimeout(), command.strip()))
|
|
|
|
|
|
|
|
|
|
def _handle_buffer_read_timeout(self, signum, frame):
|
|
|
|
|
display.vvvv("Response received, triggered 'persistent_buffer_read_timeout' timer of %s seconds"
|
|
|
|
|