From 7892aef70a32c07f576fd99d86c91af7ddf919bb Mon Sep 17 00:00:00 2001 From: Ruben Date: Fri, 26 Feb 2021 13:54:56 +0100 Subject: [PATCH] Add a warning for misconfiguration. (#509) * Add a warning for misconfiguration. As specified in the docs, by default the settings result in a configuration where slow tasks that run for more than 60s cause repeated running of tasks, which has caused a few issues. This warning doesn't change the defaults, which would be a marge larger change, but instead provides a, hopefully, helpful message to the user. * fixed missing bracket * Update conf.py fixed spelling * Update conf.py Made bool work for python 3.6+ * Fixing typo Co-authored-by: Ilan Steemers --- django_q/conf.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/django_q/conf.py b/django_q/conf.py index ba7e370..15de28a 100644 --- a/django_q/conf.py +++ b/django_q/conf.py @@ -3,6 +3,7 @@ import os from copy import deepcopy from multiprocessing import cpu_count from signal import signal +from warnings import warn import pkg_resources from django.conf import settings @@ -130,6 +131,13 @@ class Conf: # Only works with brokers that guarantee delivery. Defaults to 60 seconds. RETRY = conf.get("retry", 60) + # Verify if retry and timeout settings are correct + if not TIMEOUT or (TIMEOUT > RETRY): + warn("""Retry and timeout are misconfigured. Set retry larger than timeout, + failure to do so will cause the tasks to be retriggered before completion. + See https://django-q.readthedocs.io/en/latest/configure.html#retry for details.""") + + # Sets the amount of tasks the cluster will try to pop off the broker. # If it supports bulk gets. BULK = conf.get("bulk", 1) @@ -189,8 +197,7 @@ class Conf: # to manage workarounds during testing TESTING = conf.get("testing", False) - - + # logger logger = logging.getLogger("django-q")