Don't filter when no queues are explicitly specified.

This caused the workers from omitting empty queues from workers, as if
they were not listening on them.
This commit is contained in:
Vincent Driessen 2012-03-27 12:17:39 +02:00
parent 2e5f537abd
commit 59aebf8676
1 changed files with 9 additions and 6 deletions

View File

@ -83,19 +83,22 @@ def show_workers(args):
# Filter out workers that don't match the queue filter # Filter out workers that don't match the queue filter
ws = [w for w in Worker.all() if any_matching_queue(w)] ws = [w for w in Worker.all() if any_matching_queue(w)]
else:
qs = Queue.all()
ws = Worker.all()
if not args.by_queue:
def filter_queues(queue_names): def filter_queues(queue_names):
return [qname for qname in queue_names if Queue(qname) in qs] return [qname for qname in queue_names if Queue(qname) in qs]
for w in ws:
if not args.raw:
print '%s %s: %s' % (w.name, state_symbol(w.state), ', '.join(filter_queues(w.queue_names())))
else: else:
print 'worker %s %s %s' % (w.name, w.state, ','.join(filter_queues(w.queue_names()))) qs = Queue.all()
ws = Worker.all()
filter_queues = lambda x: x
if not args.by_queue:
for w in ws:
worker_queues = filter_queues(w.queue_names())
if not args.raw:
print '%s %s: %s' % (w.name, state_symbol(w.state), ', '.join(worker_queues))
else:
print 'worker %s %s %s' % (w.name, w.state, ','.join(worker_queues))
else: else:
# Create reverse lookup table # Create reverse lookup table
queues = {q: [] for q in qs} queues = {q: [] for q in qs}