[sql lab] handle query stop race condition (#4928)

fixes https://github.com/apache/incubator-superset/issues/4926

In rare cases where the query is stopped before it is started, SQL Lab
returns an unexpected string payload instead of a normal dictionary.

This aligns the process to handle the error in a homogeneous fashion.
This commit is contained in:
Maxime Beauchemin
2018-05-07 13:49:42 -07:00
committed by GitHub
parent a60d577b7d
commit 415d1c092b

View File

@@ -232,13 +232,7 @@ def execute_sql(
conn.close()
if query.status == utils.QueryStatus.STOPPED:
return json.dumps(
{
'query_id': query.id,
'status': query.status,
'query': query.to_dict(),
},
default=utils.json_iso_dttm_ser)
return handle_error('The query has been stopped')
cdf = convert_results_to_df(cursor_description, data)