chore: Releasing SQL Lab Celery results (#10279)

Co-authored-by: John Bodley <john.bodley@airbnb.com>
This commit is contained in:
John Bodley 2020-07-10 09:53:57 -07:00 committed by GitHub
parent 3f2f5e8311
commit 4e4ccd48d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -2101,7 +2101,7 @@ class Superset(BaseSupersetView): # pylint: disable=too-many-public-methods
logger.info("Query %i: Running query on a Celery worker", query.id)
# Ignore the celery future object and the request may time out.
try:
sql_lab.get_sql_results.delay(
task = sql_lab.get_sql_results.delay(
query.id,
rendered_query,
return_results=False,
@ -2111,6 +2111,10 @@ class Superset(BaseSupersetView): # pylint: disable=too-many-public-methods
expand_data=expand_data,
log_params=log_params,
)
# Explicitly forget the task to ensure the task metadata is removed from the
# Celery results backend in a timely manner.
task.forget()
except Exception as ex: # pylint: disable=broad-except
logger.exception("Query %i: %s", query.id, str(ex))
msg = _(