Introduced int_env and CELERY_MAX_RETRIES env variable
This commit is contained in:
parent
5a5654be01
commit
26b4feb1d1
1 changed files with 18 additions and 0 deletions
|
@ -10,6 +10,9 @@ from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
# dotenv
|
# dotenv
|
||||||
import dotenv
|
import dotenv
|
||||||
|
import logging
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def gettext(s):
|
def gettext(s):
|
||||||
|
@ -25,6 +28,20 @@ def bool_env(val):
|
||||||
return True if os.environ.get(val, False) == 'True' else False
|
return True if os.environ.get(val, False) == 'True' else False
|
||||||
|
|
||||||
|
|
||||||
|
def int_env(val, default_value=0):
|
||||||
|
"""Replaces string based environment values with Python integers
|
||||||
|
Return default_value if val is not set or cannot be parsed, otherwise
|
||||||
|
returns the python integer equal to the passed val
|
||||||
|
"""
|
||||||
|
return_value = default_value
|
||||||
|
try:
|
||||||
|
return_value = int(os.environ.get(val))
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(str(e))
|
||||||
|
|
||||||
|
return return_value
|
||||||
|
|
||||||
|
|
||||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||||
|
|
||||||
PROJECT_DIR = os.path.abspath(
|
PROJECT_DIR = os.path.abspath(
|
||||||
|
@ -529,6 +546,7 @@ CELERY_ACCEPT_CONTENT = ['application/json']
|
||||||
CELERY_TASK_SERIALIZER = 'json'
|
CELERY_TASK_SERIALIZER = 'json'
|
||||||
CELERY_RESULT_SERIALIZER = 'json'
|
CELERY_RESULT_SERIALIZER = 'json'
|
||||||
CELERY_TIMEZONE = 'Europe/Zurich'
|
CELERY_TIMEZONE = 'Europe/Zurich'
|
||||||
|
CELERY_MAX_RETRIES = int_env('CELERY_MAX_RETRIES', 5)
|
||||||
|
|
||||||
ENABLE_DEBUG_LOGGING = bool_env('ENABLE_DEBUG_LOGGING')
|
ENABLE_DEBUG_LOGGING = bool_env('ENABLE_DEBUG_LOGGING')
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue