diff --git a/django_q/brokers/__init__.py b/django_q/brokers/__init__.py index a8380ee..0d10cac 100644 --- a/django_q/brokers/__init__.py +++ b/django_q/brokers/__init__.py @@ -29,6 +29,11 @@ class Broker(object): """ pass + def lock_size(self): + """ + :return: the number of tasks currently awaiting acknowledgement + """ + def delete_queue(self): """ Deletes the queue from the broker diff --git a/django_q/monitor.py b/django_q/monitor.py index 3671e83..6a3bcf4 100644 --- a/django_q/monitor.py +++ b/django_q/monitor.py @@ -83,8 +83,9 @@ def monitor(run_once=False, broker=None): # bottom bar i += 1 queue_size = broker.queue_size() - if hasattr(broker, 'lock_size'): - queue_size = '{}({})'.format(queue_size, broker.lock_size()) + lock_size = broker.lock_size() + if lock_size: + queue_size = '{}({})'.format(queue_size, lock_size) print(term.move(i, 0) + term.white_on_cyan(term.center(broker.info(), width=col_width * 2))) print(term.move(i, 2 * col_width) + term.black_on_cyan(term.center(_('Queued'), width=col_width))) print(term.move(i, 3 * col_width) + term.white_on_cyan(term.center(queue_size, width=col_width)))