summaryrefslogtreecommitdiff
path: root/wsgitools/scgi/forkpool.py
diff options
context:
space:
mode:
Diffstat (limited to 'wsgitools/scgi/forkpool.py')
-rw-r--r--wsgitools/scgi/forkpool.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/wsgitools/scgi/forkpool.py b/wsgitools/scgi/forkpool.py
index 3106d05..df92ec3 100644
--- a/wsgitools/scgi/forkpool.py
+++ b/wsgitools/scgi/forkpool.py
@@ -56,19 +56,29 @@ class SocketFileWrapper:
raise
return self.buff + data
- def readline(self):
+ def readline(self, size=None):
"""see pep333"""
while True:
try:
split = self.buff.index('\n') + 1
+ if size is not None and split > size:
+ split = size
ret, self.buff = self.buff[:split], self.buff[split:]
return ret
except ValueError:
- data = self._recv(4096)
+ if size is not None:
+ if len(self.buff) < size:
+ data = self._recv(size - len(self.buff))
+ else:
+ ret, self.buff = self.buff[:size], self.buff[size:]
+ return ret
+ else:
+ data = self._recv(4096)
if not data:
ret, self.buff = self.buff, ""
return ret
self.buff += data
+
def readlines(self):
"""see pep333"""
data = self.readline()