From b4c286bc81c8ef380c0377f2da290e41b935cabc Mon Sep 17 00:00:00 2001 From: py Date: Tue, 30 Jul 2013 17:27:51 +0800 Subject: [PATCH] resp maybe None when pre_request raise exceptions --- gunicorn/workers/async.py | 2 +- gunicorn/workers/sync.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gunicorn/workers/async.py b/gunicorn/workers/async.py index a62dec6a..3bf963c0 100644 --- a/gunicorn/workers/async.py +++ b/gunicorn/workers/async.py @@ -105,7 +105,7 @@ class AsyncWorker(base.Worker): if resp.should_close(): raise StopIteration() except Exception: - if resp.headers_sent: + if resp and resp.headers_sent: # If the requests have already been sent, we should close the # connection to indicate the error. try: diff --git a/gunicorn/workers/sync.py b/gunicorn/workers/sync.py index 12dfacd5..347b6a28 100644 --- a/gunicorn/workers/sync.py +++ b/gunicorn/workers/sync.py @@ -144,7 +144,7 @@ class SyncWorker(base.Worker): except socket.error: raise except Exception as e: - if resp.headers_sent: + if resp and resp.headers_sent: # If the requests have already been sent, we should close the # connection to indicate the error. try: