Permalink
Browse files

Upgrade Celery to 4.2.1. (#2773)

  • Loading branch information...
emtwo authored and jezdez committed Sep 28, 2018
1 parent 4620fed commit b7656938797dacda97545d69f8e628e75dd62202
Showing with 25 additions and 13 deletions.
  1. +2 −2 redash/metrics/celery.py
  2. +16 −4 redash/settings/__init__.py
  3. +6 −6 redash/worker.py
  4. +1 −1 requirements.txt
View
@@ -12,7 +12,7 @@
@task_prerun.connect
def task_prerun_handler(signal, sender, task_id, task, args, kwargs):
def task_prerun_handler(signal, sender, task_id, task, args, kwargs, **kw):
try:
tasks_start_time[task_id] = time.time()
except Exception:
@@ -30,7 +30,7 @@ def metric_name(name, tags):
@task_postrun.connect
def task_postrun_handler(signal, sender, task_id, task, args, kwargs, retval, state):
def task_postrun_handler(signal, sender, task_id, task, args, kwargs, retval, state, **kw):
try:
run_time = 1000 * (time.time() - tasks_start_time.pop(task_id))
@@ -32,8 +32,12 @@ def all_settings():
# Celery related settings
CELERY_BROKER = os.environ.get("REDASH_CELERY_BROKER", REDIS_URL)
CELERY_BACKEND = os.environ.get("REDASH_CELERY_BACKEND", CELERY_BROKER)
CELERY_TASK_RESULT_EXPIRES = int(os.environ.get('REDASH_CELERY_TASK_RESULT_EXPIRES', 3600 * 4))
CELERY_RESULT_BACKEND = os.environ.get(
"REDASH_CELERY_RESULT_BACKEND",
os.environ.get("REDASH_CELERY_BACKEND", CELERY_BROKER))
CELERY_RESULT_EXPIRES = int(os.environ.get(
"REDASH_CELERY_RESULT_EXPIRES",
os.environ.get("REDASH_CELERY_TASK_RESULT_EXPIRES", 3600 * 4)))
# The following enables periodic job (every 5 minutes) of removing unused query results.
QUERY_RESULTS_CLEANUP_ENABLED = parse_boolean(os.environ.get("REDASH_QUERY_RESULTS_CLEANUP_ENABLED", "true"))
@@ -107,8 +111,16 @@ def all_settings():
LOG_STDOUT = parse_boolean(os.environ.get('REDASH_LOG_STDOUT', 'false'))
LOG_PREFIX = os.environ.get('REDASH_LOG_PREFIX', '')
LOG_FORMAT = os.environ.get('REDASH_LOG_FORMAT', LOG_PREFIX + '[%(asctime)s][PID:%(process)d][%(levelname)s][%(name)s] %(message)s')
CELERYD_LOG_FORMAT = os.environ.get('REDASH_CELERYD_LOG_FORMAT', LOG_PREFIX + '[%(asctime)s][PID:%(process)d][%(levelname)s][%(processName)s] %(message)s')
CELERYD_TASK_LOG_FORMAT = os.environ.get('REDASH_CELERYD_TASK_LOG_FORMAT', LOG_PREFIX + '[%(asctime)s][PID:%(process)d][%(levelname)s][%(processName)s] task_name=%(task_name)s task_id=%(task_id)s %(message)s')
CELERYD_WORKER_LOG_FORMAT = os.environ.get(
"REDASH_CELERYD_WORKER_LOG_FORMAT",
os.environ.get('REDASH_CELERYD_LOG_FORMAT',
LOG_PREFIX + '[%(asctime)s][PID:%(process)d][%(levelname)s][%(processName)s] %(message)s'))
CELERYD_WORKER_TASK_LOG_FORMAT = os.environ.get(
"REDASH_CELERYD_WORKER_TASK_LOG_FORMAT",
os.environ.get('REDASH_CELERYD_TASK_LOG_FORMAT',
(LOG_PREFIX + '[%(asctime)s][PID:%(process)d][%(levelname)s][%(processName)s] '
'task_name=%(task_name)s '
'task_id=%(task_id)s %(message)s')))
# Mail settings:
MAIL_SERVER = os.environ.get('REDASH_MAIL_SERVER', 'localhost')
View
@@ -44,12 +44,12 @@
'schedule': timedelta(minutes=5)
}
celery.conf.update(CELERY_RESULT_BACKEND=settings.CELERY_BACKEND,
CELERYBEAT_SCHEDULE=celery_schedule,
CELERY_TIMEZONE='UTC',
CELERY_TASK_RESULT_EXPIRES=settings.CELERY_TASK_RESULT_EXPIRES,
CELERYD_LOG_FORMAT=settings.CELERYD_LOG_FORMAT,
CELERYD_TASK_LOG_FORMAT=settings.CELERYD_TASK_LOG_FORMAT)
celery.conf.update(result_backend=settings.CELERY_RESULT_BACKEND,
beat_schedule=celery_schedule,
timezone='UTC',
result_expires=settings.CELERY_RESULT_EXPIRES,
worker_log_format=settings.CELERYD_WORKER_LOG_FORMAT,
worker_task_log_format=settings.CELERYD_WORKER_TASK_LOG_FORMAT)
if settings.SENTRY_DSN:
from raven import Client
View
@@ -33,7 +33,7 @@ wsgiref==0.1.2
honcho==0.5.0
statsd==2.1.2
gunicorn==19.7.1
celery==3.1.25
celery==4.2.1
jsonschema==2.4.0
RestrictedPython==3.6.0
pysaml2==4.5.0

0 comments on commit b765693

Please sign in to comment.