From 90ae38542977d4a7d508e85a524263803bbd24b3 Mon Sep 17 00:00:00 2001 From: Nicolas Le Manchet Date: Wed, 10 Oct 2018 20:16:58 +0200 Subject: [PATCH] Start worker thread number at 1 This number is only for human consumption and startng at 1 seems more user friendly to me. --- spinach/worker.py | 2 +- tests/test_worker.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/spinach/worker.py b/spinach/worker.py index 4c0c71a..cf44012 100644 --- a/spinach/worker.py +++ b/spinach/worker.py @@ -44,7 +44,7 @@ def __init__(self, num_workers: int, namespace: str): self._must_stop = threading.Event() self.poison_pill = object() - for i in range(num_workers): + for i in range(1, num_workers + 1): thread = threading.Thread( target=self._worker_func, name='{}-worker-{}'.format(self._namespace, i) diff --git a/tests/test_worker.py b/tests/test_worker.py index 0895d88..7a924e3 100644 --- a/tests/test_worker.py +++ b/tests/test_worker.py @@ -136,10 +136,10 @@ def test_worker_signals(job): mock_job_started_receiver.assert_called_once_with(ns, job=ANY) mock_job_finished_receiver.assert_called_once_with(ns, job=ANY) mock_worker_started_receiver.assert_called_once_with( - ns, worker_name='tests-worker-0' + ns, worker_name='tests-worker-1' ) mock_worker_terminated_receiver.assert_called_once_with( - ns, worker_name='tests-worker-0' + ns, worker_name='tests-worker-1' )