summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Quast <contact@jeffquast.com>2015-10-14 10:39:14 -0700
committerJeroen Demeyer <jdemeyer@cage.ugent.be>2016-01-05 11:20:37 +0100
commit98c7d93491625828dcd69dede151f4342ea333ab (patch)
treee12e5879dc2dda4ce1adb2b14ffea176193bef77
parent4a2128a00d42dc0ce90cb7cac00d0b7278a23531 (diff)
downloadpexpect-git-98c7d93491625828dcd69dede151f4342ea333ab.tar.gz
Add new spawn.delayafterread attribute.
-rw-r--r--pexpect/expect.py5
-rw-r--r--pexpect/spawnbase.py4
2 files changed, 7 insertions, 2 deletions
diff --git a/pexpect/expect.py b/pexpect/expect.py
index 6fde9e8..1c7a163 100644
--- a/pexpect/expect.py
+++ b/pexpect/expect.py
@@ -95,7 +95,8 @@ class Expecter(object):
return self.timeout()
# Still have time left, so read more data
incoming = spawn.read_nonblocking(spawn.maxread, timeout)
- time.sleep(0.0001)
+ 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:
@@ -294,4 +295,4 @@ class searcher_re(object):
self.start = first_match
self.match = the_match
self.end = self.match.end()
- return best_index \ No newline at end of file
+ return best_index
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