You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by vi...@apache.org on 2020/09/16 06:35:02 UTC

[incubator-superset] 06/28: feat: make screenshot timeout configurable (#10517)

This is an automated email from the ASF dual-hosted git repository.

villebro pushed a commit to branch 0.37
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git

commit 13928fcf2d08a46c780e0551358e4372a24734ca
Author: Jason Davis <32...@users.noreply.github.com>
AuthorDate: Tue Aug 4 17:16:31 2020 -0700

    feat: make screenshot timeout configurable (#10517)
    
    * made screenshot timeout configurable
    
    * added default value to config and refractored use
    
    * black
    
    * updated config comment
    
    * moves config variables to thumbnail section
    
    Co-authored-by: Jason Davis <@dropbox.com>
---
 superset/config.py            | 6 ++++++
 superset/utils/screenshots.py | 8 ++++----
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/superset/config.py b/superset/config.py
index 74e7fec..b8dc1d0 100644
--- a/superset/config.py
+++ b/superset/config.py
@@ -335,6 +335,12 @@ GET_FEATURE_FLAGS_FUNC: Optional[Callable[[Dict[str, bool]], Dict[str, bool]]] =
 THUMBNAIL_SELENIUM_USER = "Admin"
 THUMBNAIL_CACHE_CONFIG: CacheConfig = {"CACHE_TYPE": "null"}
 
+# Used for thumbnails and other api: Time in seconds before selenium
+# times out after trying to locate an element on the page and wait
+# for that element to load for an alert screenshot.
+SCREENSHOT_LOCATE_WAIT = 10
+SCREENSHOT_LOAD_WAIT = 60
+
 # ---------------------------------------------------
 # Image and file configuration
 # ---------------------------------------------------
diff --git a/superset/utils/screenshots.py b/superset/utils/screenshots.py
index 3c7519a..05c7518 100644
--- a/superset/utils/screenshots.py
+++ b/superset/utils/screenshots.py
@@ -159,11 +159,11 @@ class AuthWebDriverProxy:
         time.sleep(SELENIUM_HEADSTART)
         try:
             logger.debug("Wait for the presence of %s", element_name)
-            element = WebDriverWait(driver, 10).until(
-                EC.presence_of_element_located((By.CLASS_NAME, element_name))
-            )
+            element = WebDriverWait(
+                driver, current_app.config["SCREENSHOT_LOCATE_WAIT"]
+            ).until(EC.presence_of_element_located((By.CLASS_NAME, element_name)))
             logger.debug("Wait for .loading to be done")
-            WebDriverWait(driver, 60).until_not(
+            WebDriverWait(driver, current_app.config["SCREENSHOT_LOAD_WAIT"]).until_not(
                 EC.presence_of_all_elements_located((By.CLASS_NAME, "loading"))
             )
             logger.info("Taking a PNG screenshot")