From 47a92f8e56e53c4087c611d3ae2bc7f5fee2b566 Mon Sep 17 00:00:00 2001 From: Ilan Date: Mon, 17 Aug 2015 12:57:59 +0200 Subject: [PATCH 1/2] added to translations fixed _ conflict --- django_q/cluster.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/django_q/cluster.py b/django_q/cluster.py index 0b2105f..c1ed4e9 100644 --- a/django_q/cluster.py +++ b/django_q/cluster.py @@ -207,7 +207,7 @@ class Sentinel(object): self.pool = [] Stat(self).save() # spawn worker pool - for _ in range(self.pool_size): + for __ in range(self.pool_size): self.spawn_worker() # spawn auxiliary self.monitor = self.spawn_monitor() @@ -254,7 +254,7 @@ class Sentinel(object): def stop(self): Stat(self).save() name = current_process().name - logger.info('{} stopping cluster processes'.format(name)) + logger.info(_('{} stopping cluster processes').format(name)) # Stopping pusher self.event_out.set() # Wait for it to stop @@ -262,7 +262,7 @@ class Sentinel(object): sleep(0.1) Stat(self).save() # Put poison pills in the queue - for _ in range(len(self.pool)): + for __ in range(len(self.pool)): self.task_queue.put('STOP') self.task_queue.close() # wait for the task queue to empty @@ -279,7 +279,7 @@ class Sentinel(object): self.result_queue.close() # Wait for the result queue to empty self.result_queue.join_thread() - logger.info('{} waiting for the monitor.'.format(name)) + logger.info(_('{} waiting for the monitor.').format(name)) # Wait for everything to close or time out count = 0 if not self.timeout: @@ -510,4 +510,4 @@ def set_cpu_affinity(n, process_ids, actual=not Conf.TESTING): p = psutil.Process(pid) if actual: p.cpu_affinity(affinity) - logger.info('{} will use cpu {}'.format(pid, affinity)) + logger.info(_('{} will use cpu {}').format(pid, affinity)) From ac2dc02b4ca2dd388e4391f1f9b9bd700bdf4acd Mon Sep 17 00:00:00 2001 From: Ilan Date: Mon, 17 Aug 2015 14:25:32 +0200 Subject: [PATCH 2/2] consolidated redis ping --- django_q/cluster.py | 8 ++------ django_q/monitor.py | 4 +--- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/django_q/cluster.py b/django_q/cluster.py index c1ed4e9..bd3db19 100644 --- a/django_q/cluster.py +++ b/django_q/cluster.py @@ -33,16 +33,11 @@ import tasks from django_q.conf import Conf, redis_client, logger, psutil from django_q.models import Task, Success, Schedule -from django_q.monitor import Status, Stat +from django_q.monitor import Status, Stat, ping_redis class Cluster(object): def __init__(self, list_key=Conf.Q_LIST): - try: - redis_client.ping() - except Exception as e: - logger.exception(e) - raise e self.sentinel = None self.stop_event = None self.start_event = None @@ -136,6 +131,7 @@ class Sentinel(object): self.start() def start(self): + ping_redis(self.r) self.spawn_cluster() self.guard() diff --git a/django_q/monitor.py b/django_q/monitor.py index 3cbb23d..80fbb34 100644 --- a/django_q/monitor.py +++ b/django_q/monitor.py @@ -278,7 +278,5 @@ def ping_redis(r): try: r.ping() except Exception as e: - term = Terminal() - print(term.red('Can not connect to Redis server.')) - logger.exception(e) + logger.error('Can not connect to Redis server.') raise e