From 8ed010e474ef1fc5d2c1ec998741d62e2bbfe56f Mon Sep 17 00:00:00 2001 From: Helmut Grohne Date: Wed, 9 Jul 2008 21:34:57 +0200 Subject: speed up receiving data in forkpool --- wsgitools/scgi/forkpool.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'wsgitools/scgi/forkpool.py') diff --git a/wsgitools/scgi/forkpool.py b/wsgitools/scgi/forkpool.py index 3597f08..107b31a 100644 --- a/wsgitools/scgi/forkpool.py +++ b/wsgitools/scgi/forkpool.py @@ -66,12 +66,19 @@ class SocketFileWrapper: except socket.error: break return "".join(retl) - while len(self.buff) < size: + datalist = [self.buff] + datalen = len(self.buff) + while datalen < size: try: - data = self._recv(min(4096, size - len(self.buff))) + data = self._recv(min(4096, size - datalen)) except socket.error: break - self.buff += data + if not data: + break + datalist.append(data) + datalen += len(data) + self.buff = "".join(datalist) + if size <= len(self.buff): ret, self.buff = self.buff[:size], self.buff[size:] return ret -- cgit v1.2.3