fgimian / paramiko-expect

A Python expect-like extension for the Paramiko SSH library which also supports tailing logs.
MIT License
204 stars 78 forks source link

socket.timeout() raises AttributeError Exception #72

Open dgonzalez-cs opened 3 years ago

dgonzalez-cs commented 3 years ago

I'm always managing my exceptions in my code but I keep not getting the actual information of the "generic" Exception when this happens. I have at my code a part where I except Exception as e: and where I print the e but I keep getting "None". Using my debugger I saw this happening in that part. I wasn't able to print the information of the exception because of an Attribute not being found after socket.timeout() exception is risen.

image

Traceback (most recent call last):
  File "/Users/dglez/Library/Python/3.8/lib/python/site-packages/paramiko/channel.py", line 699, in recv
    out = self.in_buffer.read(nbytes, self.timeout)
  File "/Users/dglez/Library/Python/3.8/lib/python/site-packages/paramiko/buffered_pipe.py", line 164, in read
    raise PipeTimeout()
paramiko.buffered_pipe.PipeTimeout

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/dglez/myproject", line 1808, in myfunction
    myexpect.expect("some string.*", timeout=60)
  File "/Users/dglez/Library/Python/3.8/lib/python/site-packages/paramiko_expect.py", line 144, in expect
    current_buffer = self.channel.recv(self.buffer_size)
  File "/Users/dglez/Library/Python/3.8/lib/python/site-packages/paramiko/channel.py", line 701, in recv
    raise socket.timeout()
socket.timeout

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/dglez/.vscode/extensions/ms-python.python-2021.6.944021595/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_resolver.py", line 193, in _get_py_dictionary
    attr = getattr(var, name)
AttributeError: characters_written

Did I came to the right place to open this issue?

fruch commented 1 year ago

You'll need to supply a bit more information.

A code snippet showing the problem.

From what you share it look like a regular socket.timeout that being raised...