Skip to content

request timeout not working #291

Description

@lstorme

Describe the bug

A clear and concise description of what the bug is.

If you are seeing an exception, include the full exceptions details (message and stack trace).

10
Done:

To reproduce

Include a complete code listing (or project/solution) that we can run to reproduce the issue.

Partial code listings, or multiple fragments of code, will slow down our response or cause us to push the issue back to you to provide code to reproduce the issue.

Use step from https://github.com/microsoft/mssql-python/wiki/Connection


    conn = mssql_python.connect(create_dsn(), timeout=10)
    print(conn.timeout)  # 10

    # Change timeout dynamically
    conn.timeout = 10

    cursor = conn.cursor()
    try:
        # Query that might run longer than 10 seconds
        cursor.execute("WAITFOR DELAY '00:00:15'")
    except mssql_python.OperationalError as e:
        print("Query timed out:", e)
    print("Done:")

Expected behavior

A clear and concise description of what you expected to happen.
-> should see Query timed out...
-> no exception raised

Further technical details

Python version: 3.12
SQL Server version: (e.g. SQL Server 2022)
Operating system: RedHat 8

Activity

  1. sumitmsft commented on Oct 15, 2025

    @sumitmsft
    Contributor

    Hello lstorme - thanks for reporting this issue. We will triage this issue and let you know our next plan of action on this. Please allow time to revert. If this is extremely critical for your project please do let us know, so that we take it up on priority.

    Thanks again for reporting this issue.

  2. lstorme commented on Nov 19, 2025

    @lstorme
    Author

    I see release 1.0 is released but timeout isn't working ?

  3. jahnvi480 commented on Nov 25, 2025

    @jahnvi480
    Contributor

    Thank you for reporting this issue! I've confirmed the bug and implemented a complete fix. The timeout feature was not working due to missing constants and incorrect type casting in the C++ bindings.

    Verification
    Tested with your exact scenario:

    conn = mssql_python.connect(conn_str, timeout=2)
    cursor = conn.cursor()
    cursor.execute("WAITFOR DELAY '00:00:05'")  # 5 seconds

    Result: ✅ Query now properly times out after ~2 seconds with OperationalError

    The fix has been implemented in PR #348 and will be available once merged.

  4. added
    triage doneIssues that are triaged by dev team and are in investigation.
    and removed
    triage neededFor new issues, not triaged yet.
    on Nov 25, 2025
  5. jahnvi480 commented on Dec 11, 2025

    @jahnvi480
    Contributor

    lstorme PR is merged now and this will start working from next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

FIXEDarea: connectivity-authConnection lifecycle, Entra/SP/NTLM auth, tokens, TLS, conn-string parsing, Fabric endpoints.bugSomething isn't workinginADOtriage doneIssues that are triaged by dev team and are in investigation.

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions