From 40ce421051c0a54f3b3849424491882cf1339801 Mon Sep 17 00:00:00 2001 From: Jeff Quast Date: Wed, 14 Oct 2015 12:17:33 -0700 Subject: add new spawn.delayafterread attribute. this allows reverting to pre-2.0 behaior --- pexpect/expect.py | 2 ++ pexpect/spawnbase.py | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/pexpect/expect.py b/pexpect/expect.py index ae7d144..1c7a163 100644 --- a/pexpect/expect.py +++ b/pexpect/expect.py @@ -95,6 +95,8 @@ class Expecter(object): return self.timeout() # Still have time left, so read more data incoming = spawn.read_nonblocking(spawn.maxread, timeout) + if self.spawn.delayafterread is not None: + time.sleep(self.spawn.delayafterread) if timeout is not None: timeout = end_time - time.time() except EOF as e: diff --git a/pexpect/spawnbase.py b/pexpect/spawnbase.py index 0518d83..4664884 100644 --- a/pexpect/spawnbase.py +++ b/pexpect/spawnbase.py @@ -70,6 +70,10 @@ class SpawnBase(object): # Used by terminate() to give kernel time to update process status. # Time in seconds. self.delayafterterminate = 0.1 + # After each call to read_nonblocking(), pexpect releases the GIL + # through a time.sleep(0.0001) call by default since version 2.1. + # When set as value 'None', the old 2.0 behavior is restored. + self.delayafterread = 0.0001 self.softspace = False self.name = '<' + repr(self) + '>' self.closed = True -- cgit v1.2.1