diff --git a/src/waitress/task.py b/src/waitress/task.py index 8e7ab188..6350e340 100644 --- a/src/waitress/task.py +++ b/src/waitress/task.py @@ -57,8 +57,10 @@ def __init__(self): self.queue_cv = threading.Condition(self.lock) self.thread_exit_cv = threading.Condition(self.lock) - def start_new_thread(self, target, args): - t = threading.Thread(target=target, name="waitress", args=args) + def start_new_thread(self, target, thread_no): + t = threading.Thread( + target=target, name="waitress-{}".format(thread_no), args=(thread_no,) + ) t.daemon = True t.start() @@ -96,7 +98,7 @@ def set_thread_count(self, count): thread_no = thread_no + 1 threads.add(thread_no) running += 1 - self.start_new_thread(self.handler_thread, (thread_no,)) + self.start_new_thread(self.handler_thread, thread_no) self.active_count += 1 thread_no = thread_no + 1 if running > count: diff --git a/tests/test_task.py b/tests/test_task.py index 1a86245a..64668237 100644 --- a/tests/test_task.py +++ b/tests/test_task.py @@ -34,7 +34,7 @@ def test_set_thread_count_increase(self): L = [] inst.start_new_thread = lambda *x: L.append(x) inst.set_thread_count(1) - self.assertEqual(L, [(inst.handler_thread, (0,))]) + self.assertEqual(L, [(inst.handler_thread, 0)]) def test_set_thread_count_increase_with_existing(self): inst = self._makeOne() @@ -42,7 +42,7 @@ def test_set_thread_count_increase_with_existing(self): inst.threads = {0} inst.start_new_thread = lambda *x: L.append(x) inst.set_thread_count(2) - self.assertEqual(L, [(inst.handler_thread, (1,))]) + self.assertEqual(L, [(inst.handler_thread, 1)]) def test_set_thread_count_decrease(self): inst = self._makeOne()