diff options
Diffstat (limited to 'wsgitools/scgi/forkpool.py')
-rw-r--r-- | wsgitools/scgi/forkpool.py | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/wsgitools/scgi/forkpool.py b/wsgitools/scgi/forkpool.py index 055dbd1..56f1787 100644 --- a/wsgitools/scgi/forkpool.py +++ b/wsgitools/scgi/forkpool.py @@ -56,25 +56,27 @@ class SocketFileWrapper: @raise: socket.error """ if size is None: + retl = [] + data = self.buff + self.buff = "" + while data: + retl.append(data) + try: + data = self._recv() + except socket.error: + break + return "".join(retl) + while len(self.buff) < size: try: - data = self._recv() + data = self._recv(min(4096, size - len(self.buff))) except socket.error: - if self.buff: - ret, self.buff = self.buff, "" - return ret - raise - return self.buff + data + break + self.buff += data if size <= len(self.buff): ret, self.buff = self.buff[:size], self.buff[size:] return ret - try: - data = self._recv(size - len(self.buff)) - except socket.error: - if self.buff: - ret, self.buff = self.buff, "" - return self.buff - raise - return self.buff + data + ret, self.buff = self.buff, "" + return ret def readline(self, size=None): """ |