Skip to content

Commit

Permalink
Merge pull request #42 from Koed00/dev
Browse files Browse the repository at this point in the history
Replaces qsize == 0 with empty()
  • Loading branch information
Koed00 committed Aug 4, 2015
2 parents 220183b + ae0b6f6 commit 7fed9b1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion django_q/cluster.py
Expand Up @@ -143,7 +143,7 @@ def status(self):
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():
Expand Down
3 changes: 1 addition & 2 deletions django_q/tests/test_cluster.py
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions docs/monitor.rst
Expand Up @@ -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.
Expand Down Expand Up @@ -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.

0 comments on commit 7fed9b1

Please sign in to comment.