From 09357ed3c44071ad41a34f1b1b97a43010e60015 Mon Sep 17 00:00:00 2001 From: Robert Estelle Date: Sun, 12 Jul 2015 13:31:32 -0400 Subject: [PATCH] Only log '[num] workers' message when it changes. Otherwise when debug logging is on, the message prints every second even with no system activity. --- gunicorn/arbiter.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/gunicorn/arbiter.py b/gunicorn/arbiter.py index b7ee05da3..2269fd5fe 100644 --- a/gunicorn/arbiter.py +++ b/gunicorn/arbiter.py @@ -473,6 +473,8 @@ def manage_workers(self): Maintain the number of workers by spawning or killing as required. """ + orig_num_workers = self.num_workers + if len(self.WORKERS.keys()) < self.num_workers: self.spawn_workers() @@ -482,10 +484,11 @@ def manage_workers(self): (pid, _) = workers.pop(0) self.kill_worker(pid, signal.SIGTERM) - self.log.debug("{0} workers".format(len(workers)), - extra={"metric": "gunicorn.workers", - "value": len(workers), - "mtype": "gauge"}) + if self.num_workers != orig_num_workers: + self.log.debug("{0} workers".format(len(workers)), + extra={"metric": "gunicorn.workers", + "value": len(workers), + "mtype": "gauge"}) def spawn_worker(self): self.worker_age += 1