From 9c60695713d46061bce057c6df6ee94d4b6ae637 Mon Sep 17 00:00:00 2001 From: "Paul J. Davis" Date: Thu, 25 Feb 2010 09:38:32 -0500 Subject: [PATCH] Update EPIPE handling. Now ignore EPIPE tracebacks as they're most likely just notifications that a client disconnected before reading the entire response. --- gunicorn/util.py | 4 ---- gunicorn/worker.py | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/gunicorn/util.py b/gunicorn/util.py index 1e79951b..501d1e3c 100644 --- a/gunicorn/util.py +++ b/gunicorn/util.py @@ -106,7 +106,6 @@ def read_partial(sock, length): def write(sock, data): buf = "" buf += data - i = 0 while buf: try: bytes = sock.send(buf) @@ -117,10 +116,7 @@ def write(sock, data): except socket.error, e: if e[0] in (errno.EWOULDBLOCK, errno.EAGAIN): break - if e[0] == errno.EPIPE and i == 0: - continue raise - i += 1 def write_nonblock(sock, data): timeout = sock.gettimeout() diff --git a/gunicorn/worker.py b/gunicorn/worker.py index d5fe0116..34605c93 100644 --- a/gunicorn/worker.py +++ b/gunicorn/worker.py @@ -112,7 +112,7 @@ class Worker(object): self.handle(client, addr) self.nr += 1 except socket.error, e: - if e[0] not in (errno.EAGAIN, errno.ECONNABORTED): + if e[0] not in (errno.EAGAIN, errno.ECONNABORTED, errno.EPIPE): raise # Keep processing clients until no one is waiting.