Skip to content
This repository has been archived by the owner on Nov 28, 2024. It is now read-only.

Fix expect() to properly raise exception #99

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions paramiko_expect.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def expect(
:return: An EOF returns -1, a regex metch returns 0 and a match in a
list of regexes returns the index of the matched string in
the list.
:raises: A socket.timeout exception is raised on timeout.
:raises: A TimeoutError exception is raised on timeout.
"""

output_callback = output_callback if output_callback else self.output_callback
Expand Down Expand Up @@ -173,8 +173,8 @@ def expect(
while not self.channel.closed and not self.channel.recv_ready():
time.sleep(.009)
if time.time() >= (base_time + timeout):
logging.info('EXCESS TIME RECV_READY TIMEOUT, did you expect() before a send()')
return -1
logging.info('EXCESS TIME RECV_READY TIMEOUT, did you expect() before a send()?')
raise TimeoutError('{} not in response, {}s timeout exceeded'.format(re_strings,timeout))
# Read some of the output
current_buffer = self.channel.recv(self.buffer_size)

Expand Down