diff options
author | dluyer <53582923+dluyer@users.noreply.github.com> | 2020-01-09 14:44:32 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-09 14:44:32 -0800 |
commit | c58e7e7d52a3f4471baf24748ffb0fb12526f686 (patch) | |
tree | 56a23638f70fe6e196979a9d89e8d2f3fbd232ea /pexpect | |
parent | 5f98ced27fcd4477776c2793e033794955b25bcd (diff) | |
download | pexpect-c58e7e7d52a3f4471baf24748ffb0fb12526f686.tar.gz |
Updated expect_loop for split new_data
Diffstat (limited to 'pexpect')
-rw-r--r-- | pexpect/expect.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/pexpect/expect.py b/pexpect/expect.py index 7d0c7ab..572bd58 100644 --- a/pexpect/expect.py +++ b/pexpect/expect.py @@ -158,12 +158,10 @@ class Expecter(object): end_time = time.time() + timeout try: - incoming = None + idx = self.existing_data() + if idx is not None: + return idx while True: - idx = self.new_data(incoming) - # Keep reading until exception or return. - if idx is not None: - return idx # No match at this point if (timeout is not None) and (timeout < 0): return self.timeout() @@ -171,6 +169,10 @@ class Expecter(object): incoming = spawn.read_nonblocking(spawn.maxread, timeout) if self.spawn.delayafterread is not None: time.sleep(self.spawn.delayafterread) + idx = self.new_data(incoming) + # Keep reading until exception or return. + if idx is not None: + return idx if timeout is not None: timeout = end_time - time.time() except EOF as e: |