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 <koed00@gmail.com>
This commit is contained in:
Ruben
2021-02-26 13:54:56 +01:00
committed by GitHub
parent 7d03536e89
commit 7892aef70a

View File

@@ -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")