Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions superset/views/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import pandas as pd
import simplejson as json
import sqlalchemy as sqla
from sqlalchemy import and_, create_engine, MetaData, or_, update
from sqlalchemy import create_engine, MetaData, or_
from sqlalchemy.engine.url import make_url
from sqlalchemy.exc import IntegrityError
from werkzeug.routing import BaseConverter
Expand Down Expand Up @@ -2752,12 +2752,10 @@ def queries(self, last_updated_ms):
]

if queries_to_timeout:
update(Query).where(
and_(
Query.user_id == g.user.get_id(),
Query.client_id in queries_to_timeout,
),
).values(state=QueryStatus.TIMED_OUT)
for q in sql_queries:
Copy link
Copy Markdown
Member

@john-bodley john-bodley May 2, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How many SQL queries are there? It may be more efficient to have the database (like before) handle this logic.

The issue here is that update(...) returns an expression which then needs to be executed and committed.

if q.client_id in queries_to_timeout:
q.status = QueryStatus.TIMED_OUT
db.session.commit()

for client_id in queries_to_timeout:
dict_queries[client_id]['status'] = QueryStatus.TIMED_OUT
Expand Down