fgimian / paramiko-expect

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

Expect hanging when self.current_output is too large #63

Open oskrdt opened 4 years ago

oskrdt commented 4 years ago

I have a process that is monitoring the install/boot progress with paramiko expect, but when monitoring a specific very large system that produces a huge amount of output per minute, it seems that expect method hangs and it's not even failing for the timeout as it should. When debugging, I realized that the condition where is trying to match the regex strings is rapidly increasing the time it takes to execute.

            not [re_string
                 for re_string in re_strings
                 if re.match(default_match_prefix + re_string + '$',
                             self.current_output, re.DOTALL)]

So it seems the time it takes to look for a match on self.current_output is taking more than the time the buffer gets filled up again.

fruch commented 3 years ago

@oskrdt yep the design of it doesn't take into account very big output.

it should be kind of cyclic buffer.

Anyhow PRs are welcomed

sar772004 commented 3 years ago

Please check 0.3.0, should have a fix for this. If it works for you we can close this

dgonzalez-cs commented 3 years ago

I'm working with @oskrdt in the same project checking this, and it seems that we're blocked by #67 since the latest version I can gather is 0.2.9 instead of 0.3.0 I tried both python3 -m pip install --upgrade paramiko-expect and python3 -m pip install git+https://github.com/fgimian/paramiko-expect.git and I can't get the latest version (0.3.0)