def rq_stats(): queue = get_queue() failed_queue = get_failed_queue() try: workers = Worker.all(queue.connection) except ConnectionError: return None num_workers = len(workers) is_running = len(queue.connection.smembers(Worker.redis_workers_keys)) > 0 if is_running: # Translators: this refers to the status of the background job worker status_msg = ungettext('Running (%d worker)', 'Running (%d workers)', num_workers) % num_workers else: # Translators: this refers to the status of the background job worker status_msg = _('Stopped') result = { 'job_count': queue.count, 'failed_job_count': failed_queue.count, 'is_running': is_running, 'status_msg': status_msg, } return result
def handle_noargs(self, **options): # The script prefix needs to be set here because the generated URLs # need to be aware of that and they are cached. Ideally Django should # take care of setting this up, but it doesn't yet (fixed in Django # 1.10): https://code.djangoproject.com/ticket/16734 script_name = (u'/' if settings.FORCE_SCRIPT_NAME is None else force_unicode(settings.FORCE_SCRIPT_NAME)) set_script_prefix(script_name) failed_queue = get_failed_queue() for job_id in failed_queue.get_job_ids(): failed_queue.requeue(job_id=job_id)
def handle_noargs(self, **options): # The script prefix needs to be set here because the generated # URLs need to be aware of that and they are cached. Ideally # Django should take care of setting this up, but it doesn't yet: # https://code.djangoproject.com/ticket/16734 script_name = (u'/' if settings.FORCE_SCRIPT_NAME is None else force_unicode(settings.FORCE_SCRIPT_NAME)) set_script_prefix(script_name) failed_queue = get_failed_queue() for job_id in failed_queue.get_job_ids(): failed_queue.requeue(job_id=job_id)
def rq_stats(): queue = get_queue() failed_queue = get_failed_queue() workers = Worker.all(queue.connection) is_running = False if len(workers) == 1: is_running = not workers[0].stopped result = { 'job_count': queue.count, 'failed_job_count': failed_queue.count, 'is_running': is_running, } return result
def handle(self, **options): failed_queue = get_failed_queue() for job_id in failed_queue.get_job_ids(): failed_queue.requeue(job_id=job_id)