diff options
author | Eli Collins <elic@assurancetechnologies.com> | 2013-12-18 10:15:10 -0500 |
---|---|---|
committer | Eli Collins <elic@assurancetechnologies.com> | 2013-12-18 10:15:10 -0500 |
commit | 6c52026671e2b75ecd1b504881fe78dda771d98d (patch) | |
tree | 6a321d6f954f107d4251e3ce00e4fe266e291f1b | |
parent | 169558586d477f6f22402300422b90b5334b3654 (diff) | |
download | waitress-6c52026671e2b75ecd1b504881fe78dda771d98d.tar.gz |
Fix: start_response() should only re-raise exc_info if headers have been written
-rw-r--r-- | waitress/task.py | 2 | ||||
-rw-r--r-- | waitress/tests/test_task.py | 16 |
2 files changed, 16 insertions, 2 deletions
diff --git a/waitress/task.py b/waitress/task.py index a4c8f2e..ab3282f 100644 --- a/waitress/task.py +++ b/waitress/task.py @@ -346,7 +346,7 @@ class WSGITask(Task): "without providing exc_info.") if exc_info: try: - if self.complete: + if self.wrote_header: # higher levels will catch and handle raised exception: # 1. "service" method in task.py # 2. "service" method in channel.py diff --git a/waitress/tests/test_task.py b/waitress/tests/test_task.py index 8cae8dc..5bdd270 100644 --- a/waitress/tests/test_task.py +++ b/waitress/tests/test_task.py @@ -356,10 +356,14 @@ class TestWSGITask(unittest.TestCase): def test_execute_app_calls_start_response_w_exc_info_complete(self): def app(environ, start_response): start_response('200 OK', [], [ValueError, ValueError(), None]) + return [b'a'] inst = self._makeOne() inst.complete = True inst.channel.server.application = app - self.assertRaises(ValueError, inst.execute) + inst.execute() + self.assertTrue(inst.complete) + self.assertEqual(inst.status, '200 OK') + self.assertTrue(inst.channel.written) def test_execute_app_calls_start_response_w_exc_info_incomplete(self): def app(environ, start_response): @@ -373,6 +377,16 @@ class TestWSGITask(unittest.TestCase): self.assertEqual(inst.status, '200 OK') self.assertTrue(inst.channel.written) + def test_execute_app_calls_start_response_w_header_written(self): + def app(environ, start_response): + start_response('200 OK', [], [ValueError, ValueError(), None]) + return [b'a'] + inst = self._makeOne() + inst.complete = True + inst.wrote_header = True + inst.channel.server.application = app + self.assertRaises(ValueError, inst.execute) + def test_execute_bad_header_key(self): def app(environ, start_response): start_response('200 OK', [(None, 'a')]) |