Browse Source

celeryd: Don't emit "queue is empty" message if settings.CELERYD_EMPTY_MSG_EMIT_EVERY is 0.

Ask Solem 16 years ago
parent
commit
43a9302050
1 changed files with 7 additions and 4 deletions
  1. 7 4
      celery/worker.py

+ 7 - 4
celery/worker.py

@@ -31,6 +31,7 @@ class TaskDaemon(object):
     concurrency = DAEMON_CONCURRENCY
     logfile = DAEMON_LOG_FILE
     queue_wakeup_after = QUEUE_WAKEUP_AFTER
+    empty_msg_emit_every = EMPTY_MSG_EMIT_EVERY
     
     def __init__(self, concurrency=None, logfile=None, loglevel=None,
             queue_wakeup_after=None):
@@ -91,10 +92,12 @@ class TaskDaemon(object):
                 # probably because it got an exception.
                 continue
             except EmptyQueue:
-                if not last_empty_emit or \
-                        time.time() > last_empty_emit + EMPTY_MSG_EMIT_EVERY:
-                    self.logger.info("Waiting for queue.")
-                    last_empty_emit = time.time()
+                emit_every = self.empty_msg_emit_every
+                if emit_every:
+                    if not last_empty_emit or \
+                            time.time() > last_empty_emit + emit_every:
+                        self.logger.info("Waiting for queue.")
+                        last_empty_emit = time.time()
                 time.sleep(self.queue_wakeup_after)
                 continue
             except UnknownTask, e: