mirror of
https://github.com/django-q2/django-q2.git
synced 2026-10-05 06:38:12 +08:00
Adds lock count to monitor for orm broker
This commit is contained in:
+4
-1
@@ -82,9 +82,12 @@ def monitor(run_once=False, broker=None):
|
|||||||
i += 1
|
i += 1
|
||||||
# bottom bar
|
# bottom bar
|
||||||
i += 1
|
i += 1
|
||||||
|
queue_size = broker.queue_size()
|
||||||
|
if Conf.ORM:
|
||||||
|
queue_size = '{}({})'.format(queue_size, broker.lock_size())
|
||||||
print(term.move(i, 0) + term.white_on_cyan(term.center(broker.info(), width=col_width * 2)))
|
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, 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(broker.queue_size(), width=col_width)))
|
print(term.move(i, 3 * col_width) + term.white_on_cyan(term.center(queue_size, width=col_width)))
|
||||||
print(term.move(i, 4 * col_width) + term.black_on_cyan(term.center(_('Success'), width=col_width)))
|
print(term.move(i, 4 * col_width) + term.black_on_cyan(term.center(_('Success'), width=col_width)))
|
||||||
print(term.move(i, 5 * col_width) + term.white_on_cyan(
|
print(term.move(i, 5 * col_width) + term.white_on_cyan(
|
||||||
term.center(models.Success.objects.count(), width=col_width)))
|
term.center(models.Success.objects.count(), width=col_width)))
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ from django_q import async
|
|||||||
from django_q.cluster import Cluster
|
from django_q.cluster import Cluster
|
||||||
from django_q.monitor import monitor, info
|
from django_q.monitor import monitor, info
|
||||||
from django_q.status import Stat
|
from django_q.status import Stat
|
||||||
|
from django_q.conf import Conf
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
@@ -22,6 +23,10 @@ def test_monitor():
|
|||||||
assert stat.empty_queues() is True
|
assert stat.empty_queues() is True
|
||||||
break
|
break
|
||||||
assert found_c is True
|
assert found_c is True
|
||||||
|
# test lock size for orm broker
|
||||||
|
Conf.ORM = 'default'
|
||||||
|
monitor(run_once=True)
|
||||||
|
Conf.ORM = None
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
|
|||||||
Reference in New Issue
Block a user