diff options
author | Michael Merickel <michael@merickel.org> | 2019-04-02 21:54:29 -0500 |
---|---|---|
committer | Michael Merickel <michael@merickel.org> | 2019-04-02 22:29:42 -0500 |
commit | c083d0b7a645fe75c6a0ab0393be844cf2caf046 (patch) | |
tree | 3432b6287e3a18114d4158015ed74baf4d8c86ad | |
parent | 34af957c1472aca30650f75698da467ca037d8f1 (diff) | |
download | waitress-c083d0b7a645fe75c6a0ab0393be844cf2caf046.tar.gz |
get rid of JustTesting hookqueue-depth-warnings
-rw-r--r-- | waitress/task.py | 5 | ||||
-rw-r--r-- | waitress/tests/test_task.py | 25 |
2 files changed, 13 insertions, 17 deletions
diff --git a/waitress/task.py b/waitress/task.py index f0372aa..a252de5 100644 --- a/waitress/task.py +++ b/waitress/task.py @@ -47,9 +47,6 @@ hop_by_hop = frozenset(( )) -class JustTesting(Exception): - pass - ThreadIdle = 1 ThreadBusy = 2 @@ -90,8 +87,6 @@ class ThreadedTaskDispatcher(object): except Exception as e: self.logger.exception( 'Exception when servicing %r' % task) - if isinstance(e, JustTesting): - break finally: with self.queue_lock: self.stop_count -= 1 diff --git a/waitress/tests/test_task.py b/waitress/tests/test_task.py index ecb0b52..6045bf7 100644 --- a/waitress/tests/test_task.py +++ b/waitress/tests/test_task.py @@ -9,18 +9,22 @@ class TestThreadedTaskDispatcher(unittest.TestCase): def test_handler_thread_task_is_None(self): inst = self._makeOne() - inst.threads[0] = True + inst.threads[0] = 1 inst.queue.append(None) inst.handler_thread(0) self.assertEqual(inst.stop_count, -1) self.assertEqual(inst.threads, {}) def test_handler_thread_task_raises(self): - from waitress.task import JustTesting inst = self._makeOne() - inst.threads[0] = True + inst.threads[0] = 1 inst.logger = DummyLogger() - task = DummyTask(JustTesting) + class BadDummyTask(DummyTask): + def service(self): + super(BadDummyTask, self).service() + inst.threads.clear() + raise Exception + task = BadDummyTask() inst.logger = DummyLogger() inst.queue.append(task) inst.handler_thread(0) @@ -80,7 +84,11 @@ class TestThreadedTaskDispatcher(unittest.TestCase): self.assertEqual(len(inst.queue_logger.logged), 2) def test_add_task_defer_raises(self): - task = DummyTask(ValueError) + class BadDummyTask(DummyTask): + def defer(self): + super(BadDummyTask, self).defer() + raise ValueError + task = BadDummyTask() inst = self._makeOne() self.assertRaises(ValueError, inst.add_task, task) self.assertEqual(len(inst.queue), 0) @@ -1473,18 +1481,11 @@ class DummyTask(object): deferred = False cancelled = False - def __init__(self, toraise=None): - self.toraise = toraise - def service(self): self.serviced = True - if self.toraise: - raise self.toraise def defer(self): self.deferred = True - if self.toraise: - raise self.toraise def cancel(self): self.cancelled = True |