Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Commit

Permalink
[fix] checks for stopped queries (apache#8097)
Browse files Browse the repository at this point in the history
(cherry picked from commit e6956f8)
  • Loading branch information
serenajiang committed Aug 26, 2019
1 parent ef47e25 commit d3d2f73
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions superset/sql_lab.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ def execute_sql_statements(
logging.info(f"Query {query_id}: 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,
Expand All @@ -274,7 +275,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(f"Query {query_id}: {msg}")
query.set_extra_json_key("progress", msg)
Expand All @@ -283,7 +289,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:
Expand Down

0 comments on commit d3d2f73

Please sign in to comment.