This is an automated email from the ASF dual-hosted git repository.
maximebeauchemin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
The following commit(s) were added to refs/heads/master by this push:
new e6956f8 [fix] checks for stopped queries (#8097)
e6956f8 is described below
commit e6956f84b49e3906635857135dc63082e899fa14
Author: serenajiang <[email protected]>
AuthorDate: Thu Aug 22 22:23:44 2019 -0700
[fix] checks for stopped queries (#8097)
---
superset/sql_lab.py | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/superset/sql_lab.py b/superset/sql_lab.py
index 8d8aa16..fc46556 100644
--- a/superset/sql_lab.py
+++ b/superset/sql_lab.py
@@ -256,6 +256,7 @@ def execute_sql_statements(
logging.info("Set query to 'running'")
query.status = QueryStatus.RUNNING
query.start_running_time = now_as_float()
+ session.commit()
engine = database.get_sqla_engine(
schema=query.schema,
@@ -269,7 +270,12 @@ def execute_sql_statements(
with closing(conn.cursor()) as cursor:
statement_count = len(statements)
for i, statement in enumerate(statements):
- # TODO CHECK IF STOPPED
+ # Check if stopped
+ query = get_query(query_id, session)
+ if query.status == QueryStatus.STOPPED:
+ return
+
+ # Run statement
msg = f"Running statement {i+1} out of {statement_count}"
logging.info(msg)
query.set_extra_json_key("progress", msg)
@@ -278,7 +284,6 @@ def execute_sql_statements(
cdf = execute_sql_statement(
statement, query, user_name, session, cursor
)
- msg = f"Running statement {i+1} out of {statement_count}"
except Exception as e:
msg = str(e)
if statement_count > 1: