summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Quast <contact@jeffquast.com>2015-10-14 12:17:33 -0700
committerJeff Quast <contact@jeffquast.com>2015-10-14 12:17:33 -0700
commit40ce421051c0a54f3b3849424491882cf1339801 (patch)
tree439e35f3e43a72d44b25ec769b36e7f727c71f88
parent026b95675cb7b32ce8a5a0e83ba338b9ef8a3b78 (diff)
downloadpexpect-git-superfluous-sleep.tar.gz
add new spawn.delayafterread attribute.superfluous-sleep
this allows reverting to pre-2.0 behaior
-rw-r--r--pexpect/expect.py2
-rw-r--r--pexpect/spawnbase.py4
2 files changed, 6 insertions, 0 deletions
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