From f470fbf97568fdae75d9f4724848fdd8415584ed Mon Sep 17 00:00:00 2001 From: Ilan Date: Tue, 4 Aug 2015 18:30:07 +0200 Subject: [PATCH 1/2] uses empty() instead of qsize() == 0 --- django_q/cluster.py | 2 +- django_q/tests/test_cluster.py | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/django_q/cluster.py b/django_q/cluster.py index 7329f81..ba4fa3e 100644 --- a/django_q/cluster.py +++ b/django_q/cluster.py @@ -143,7 +143,7 @@ class Sentinel(object): if not self.start_event.is_set() and not self.stop_event.is_set(): return Conf.STARTING elif self.start_event.is_set() and not self.stop_event.is_set(): - if Conf.QSIZE and self.result_queue.qsize() == 0 and self.task_queue.qsize() == 0: + if self.result_queue.empty() and self.task_queue.empty(): return Conf.IDLE return Conf.WORKING elif self.stop_event.is_set() and self.start_event.is_set(): diff --git a/django_q/tests/test_cluster.py b/django_q/tests/test_cluster.py index 7d956b6..684bb86 100644 --- a/django_q/tests/test_cluster.py +++ b/django_q/tests/test_cluster.py @@ -55,8 +55,7 @@ def test_cluster_initial(r): assert c.is_starting is False sleep(0.5) stat = c.stat - if Conf.QSIZE: - assert stat.status == Conf.IDLE + assert stat.status == Conf.IDLE assert c.stop() is True assert c.sentinel.is_alive() is False assert c.has_stopped From ae0b6f6f8cef13ae887b4215ba4ae8829136a486 Mon Sep 17 00:00:00 2001 From: Ilan Date: Tue, 4 Aug 2015 18:36:52 +0200 Subject: [PATCH 2/2] updated docs --- docs/monitor.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/monitor.rst b/docs/monitor.rst index 7e99a4a..4bc1aec 100644 --- a/docs/monitor.rst +++ b/docs/monitor.rst @@ -30,7 +30,7 @@ State Current state of the cluster: - **Starting** The cluster is spawning workers and getting ready. -- **Idle** Everything is ok, but there are no tasks to process. [#f1]_ +- **Idle** Everything is ok, but there are no tasks to process. - **Working** Processing tasks like a good cluster should. - **Stopping** The cluster does not take on any new tasks and is finishing. - **Stopped** All tasks have been processed and the cluster is shutting down. @@ -154,4 +154,4 @@ Reference .. rubric:: Footnotes -.. [#f1] Uses :meth:`multiprocessing.Queue.qsize()` which is not implemented on OS X. +.. [#f1] Uses :meth:`multiprocessing.Queue.qsize()` which is not implemented on OS X and always returns 0.