Skip to content

Commit

Permalink
Set default query execution time limit to unlimited (#4626)
Browse files Browse the repository at this point in the history
* default query execution time limit to 1 hour

* use -1 (run infinitely)  as a default limit
  • Loading branch information
Omer Lachish authored Feb 11, 2020
1 parent 9646156 commit ddb0ef1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
8 changes: 8 additions & 0 deletions redash/settings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,14 @@
os.environ.get("REDASH_STATIC_ASSETS_PATH", "../client/dist/")
)

# Time limit (in seconds) for scheduled queries. Set this to -1 to execute without a time limit.
SCHEDULED_QUERY_TIME_LIMIT = int(
os.environ.get("REDASH_SCHEDULED_QUERY_TIME_LIMIT", -1)
)

# Time limit (in seconds) for adhoc queries. Set this to -1 to execute without a time limit.
ADHOC_QUERY_TIME_LIMIT = int(os.environ.get("REDASH_ADHOC_QUERY_TIME_LIMIT", -1))

JOB_EXPIRY_TIME = int(os.environ.get("REDASH_JOB_EXPIRY_TIME", 3600 * 12))
JOB_DEFAULT_FAILURE_TTL = int(
os.environ.get("REDASH_JOB_DEFAULT_FAILURE_TTL", 7 * 24 * 60 * 60)
Expand Down
16 changes: 5 additions & 11 deletions redash/settings/dynamic_settings.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
import os
from .helpers import int_or_none


# Replace this method with your own implementation in case you want to limit the time limit on certain queries or users.
def query_time_limit(is_scheduled, user_id, org_id):
scheduled_time_limit = int_or_none(
os.environ.get("REDASH_SCHEDULED_QUERY_TIME_LIMIT", None)
)
adhoc_time_limit = int_or_none(
os.environ.get("REDASH_ADHOC_QUERY_TIME_LIMIT", None)
)
from redash import settings

return scheduled_time_limit if is_scheduled else adhoc_time_limit
if is_scheduled:
return settings.SCHEDULED_QUERY_TIME_LIMIT
else:
return settings.ADHOC_QUERY_TIME_LIMIT


def periodic_jobs():
Expand Down

0 comments on commit ddb0ef1

Please sign in to comment.