Add configurable query timeout via MSSQL_QUERY_TIMEOUT environment variable - #41
Open
MWC914 wants to merge 2 commits into
Open
Add configurable query timeout via MSSQL_QUERY_TIMEOUT environment variable#41MWC914 wants to merge 2 commits into
MWC914 wants to merge 2 commits into
Conversation
Fixes RichardHan#40 Adds timeout to get_db_config() so all pymssql.connect() calls inherit a per-query timeout. Defaults to 300 seconds. Configurable via MSSQL_QUERY_TIMEOUT environment variable. Adds pymssql.OperationalError handler in call_tool() for a clean timeout error message.
Added MSSQL_QUERY_TIMEOUT to the Optional Settings section so users know the timeout is configurable without having to read the source code.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #40
Without a query timeout, queries that run longer than expected execute
indefinitely with no automatic termination.
Changes:
config["timeout"] = int(os.getenv("MSSQL_QUERY_TIMEOUT", "300"))to
get_db_config()so the timeout flows through to all threepymssql.connect() calls automatically
pymssql.OperationalErrorhandler incall_tool()to returna clean timeout error message rather than a generic exception
MSSQL_QUERY_TIMEOUTin README under Optional SettingsDefaults to 300 seconds. Tested on Windows with Windows Authentication.