From e84422530b3948d9be6e0433d7b68dbe079a8219 Mon Sep 17 00:00:00 2001 From: ilan Date: Wed, 5 Apr 2017 16:44:21 +0300 Subject: [PATCH] Fixes merge conflicts --- django_q/management/commands/qinfo.py | 13 +++++++++++-- django_q/monitor.py | 11 +++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/django_q/management/commands/qinfo.py b/django_q/management/commands/qinfo.py index 6647f4ff..cdd82bfd 100644 --- a/django_q/management/commands/qinfo.py +++ b/django_q/management/commands/qinfo.py @@ -3,7 +3,7 @@ from django_q import VERSION from django_q.conf import Conf -from django_q.monitor import info +from django_q.monitor import info, get_ids class Command(BaseCommand): @@ -18,9 +18,18 @@ def add_arguments(self, parser): default=False, help='Print current configuration.', ) + parser.add_argument( + '--ids', + action='store_true', + dest='ids', + default=False, + help='Print cluster task ID(s) (PIDs).', + ) def handle(self, *args, **options): - if options.get('config', False): + if options.get('ids', True): + get_ids() + elif options.get('config', False): hide = ['conf', 'IDLE', 'STOPPING', 'STARTING', 'WORKING', 'SIGNAL_NAMES', 'STOPPED'] settings = [a for a in dir(Conf) if not a.startswith('__') and a not in hide] self.stdout.write('VERSION: {}'.format('.'.join(str(v) for v in VERSION))) diff --git a/django_q/monitor.py b/django_q/monitor.py index 03582bff..001b53d1 100644 --- a/django_q/monitor.py +++ b/django_q/monitor.py @@ -187,3 +187,14 @@ def info(broker=None): term.white('{0:.4f}'.format(exec_time)) ) return True + + +def get_ids(): + # prints id (PID) of running clusters + stat = Stat.get_all() + if stat: + for s in stat: + print(s.cluster_id) + else: + print('No clusters appear to be running.') + return True