fix(alerts, thumbnails): celery tasks using flask-sqlalchemy sessions (#11950)

* fix(alerts, thumbnails): celery tasks using flask-sqlalchemy sessions

* selenium user is case sensitive
This commit is contained in:
Daniel Vaz Gaspar
2020-12-08 13:03:32 +00:00
committed by GitHub
parent 05258ebc6c
commit 7e6f04fce4
4 changed files with 30 additions and 4 deletions

View File

@@ -24,6 +24,7 @@ from flask import current_app
from superset import app, security_manager, thumbnail_cache
from superset.extensions import celery_app
from superset.utils.celery import session_scope
from superset.utils.screenshots import ChartScreenshot, DashboardScreenshot
from superset.utils.webdriver import WindowSize
@@ -44,7 +45,10 @@ def cache_chart_thumbnail(
return None
logger.info("Caching chart: %s", url)
screenshot = ChartScreenshot(url, digest)
user = security_manager.find_user(current_app.config["THUMBNAIL_SELENIUM_USER"])
with session_scope(nullpool=True) as session:
user = security_manager.get_user_by_username(
current_app.config["THUMBNAIL_SELENIUM_USER"], session=session
)
screenshot.compute_and_cache(
user=user,
cache=thumbnail_cache,
@@ -65,7 +69,10 @@ def cache_dashboard_thumbnail(
return
logger.info("Caching dashboard: %s", url)
screenshot = DashboardScreenshot(url, digest)
user = security_manager.find_user(current_app.config["THUMBNAIL_SELENIUM_USER"])
with session_scope(nullpool=True) as session:
user = security_manager.get_user_by_username(
current_app.config["THUMBNAIL_SELENIUM_USER"], session=session
)
screenshot.compute_and_cache(
user=user, cache=thumbnail_cache, force=force, thumb_size=thumb_size,
)