Skip to content

Commit 7ea4e51

Browse files
committed
Add event key to queue depths
1 parent 939928a commit 7ea4e51

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ To start a worker:
213213
- The `--rate_limit` flag is optional, and will default to `1`. It is the minimum number of seconds that must have elapsed before a subsequent job can be run.
214214

215215
##### manage.py queue_depth
216-
If you'd like to check your queue depth from the command line, you can run `manage.py queue_depth [queue_name]` and any
216+
If you'd like to check your queue depth from the command line, you can run `manage.py queue_depth [queue_name [queue_name ...]]` and any
217217
jobs in the "NEW" or "READY" states will be returned.
218218

219219
**Important:** If you misspell or provide a queue name which does not have any jobs, a depth of 0 will always be returned.

django_dbq/management/commands/queue_depth.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@ def handle(self, *args, **options):
1313
queue_names = options["queue_name"]
1414
queue_depths = Job.get_queue_depths()
1515

16+
queue_depths_string = " ".join(
17+
[
18+
"{queue_name}={queue_depth}".format(
19+
queue_name=queue_name, queue_depth=queue_depths.get(queue_name, 0),
20+
)
21+
for queue_name in queue_names
22+
]
23+
)
24+
1625
self.stdout.write(
17-
" ".join(
18-
[
19-
"{queue_name}={queue_depth}".format(
20-
queue_name=queue_name,
21-
queue_depth=queue_depths.get(queue_name, 0),
22-
)
23-
for queue_name in queue_names
24-
]
25-
)
26+
"event=queue_depths {queue_depths}".format(queue_depths=queue_depths_string)
2627
)

django_dbq/tests.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def test_queue_depth(self):
117117
stdout = StringIO()
118118
call_command("queue_depth", stdout=stdout)
119119
output = stdout.getvalue()
120-
self.assertEqual(output.strip(), "default=2")
120+
self.assertEqual(output.strip(), "event=queue_depths default=2")
121121

122122
def test_queue_depth_multiple_queues(self):
123123

@@ -136,13 +136,13 @@ def test_queue_depth_multiple_queues(self):
136136
stdout = StringIO()
137137
call_command("queue_depth", queue_name=("default", "testqueue",), stdout=stdout)
138138
output = stdout.getvalue()
139-
self.assertEqual(output.strip(), "default=2 testqueue=2")
139+
self.assertEqual(output.strip(), "event=queue_depths default=2 testqueue=2")
140140

141141
def test_queue_depth_for_queue_with_zero_jobs(self):
142142
stdout = StringIO()
143143
call_command("queue_depth", queue_name=("otherqueue",), stdout=stdout)
144144
output = stdout.getvalue()
145-
self.assertEqual(output.strip(), "otherqueue=0")
145+
self.assertEqual(output.strip(), "event=queue_depths otherqueue=0")
146146

147147

148148
@freezegun.freeze_time()

0 commit comments

Comments
 (0)