Skip to content

Refactor DatabricksSqlHook timeout handling to use explicit signaling - #62623

Merged
potiuk merged 1 commit into
apache:mainfrom
SameerMesiah97:DatabricksSqlHook-Timeout-Event
Mar 10, 2026
Merged

Refactor DatabricksSqlHook timeout handling to use explicit signaling#62623
potiuk merged 1 commit into
apache:mainfrom
SameerMesiah97:DatabricksSqlHook-Timeout-Event

Conversation

@SameerMesiah97

Copy link
Copy Markdown
Contributor

Description

This change refactors timeout handling in DatabricksSqlHook.run() to replace implicit timeout detection based on Timer.is_alive() with explicit signaling using a threading.Event. Previously, timeout classification relied on inferring whether the background timer thread had completed, which coupled error handling logic to thread lifecycle behavior. This refactor introduces explicit timeout signaling in create_timeout_thread() and updates run() to check that signal instead of inspecting thread state.

The refactor preserves existing cancellation semantics and exception types while removing reliance on thread liveness inference.

Rationale

The previous implementation inferred timeout occurrence from the lifecycle state of a threading.Timer, making the logic harder to reason about and tests dependent on implicit thread behavior. The inline TODO noted that this logic should be adjusted to make testing easier. By introducing explicit timeout signaling, timeout classification becomes deterministic, clearer, and easier to test without relying on thread internals.

Tests

Timeout-related tests were updated to simulate timeout conditions by mocking create_timeout_thread and the associated timeout signal rather than relying on threading.Timer behavior.

Backwards Compatibility

No changes to public APIs or behavior.

Replace implicit timeout detection based on Timer.is_alive() with explicit
timeout signaling via threading.Event. Timeout classification now checks an
explicit signal set by the timeout callback instead of inferring state from
thread lifecycle behavior.

Preserves existing cancellation semantics and exception types. Unit tests have been adjusted accordingly.
@SameerMesiah97
SameerMesiah97 force-pushed the DatabricksSqlHook-Timeout-Event branch from 45a9dfa to dfe1ab6 Compare February 28, 2026 13:12
@SameerMesiah97

Copy link
Copy Markdown
Contributor Author

Requesting review for this.

@potiuk
potiuk merged commit af80c49 into apache:main Mar 10, 2026
90 checks passed
dominikhei pushed a commit to dominikhei/airflow that referenced this pull request Mar 11, 2026
…ing (apache#62623)

Replace implicit timeout detection based on Timer.is_alive() with explicit
timeout signaling via threading.Event. Timeout classification now checks an
explicit signal set by the timeout callback instead of inferring state from
thread lifecycle behavior.

Preserves existing cancellation semantics and exception types. Unit tests have been adjusted accordingly.

Co-authored-by: Sameer Mesiah <smesiah971@gmail.com>
Pyasma pushed a commit to Pyasma/airflow that referenced this pull request Mar 13, 2026
…ing (apache#62623)

Replace implicit timeout detection based on Timer.is_alive() with explicit
timeout signaling via threading.Event. Timeout classification now checks an
explicit signal set by the timeout callback instead of inferring state from
thread lifecycle behavior.

Preserves existing cancellation semantics and exception types. Unit tests have been adjusted accordingly.

Co-authored-by: Sameer Mesiah <smesiah971@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants