Refactor DatabricksSqlHook timeout handling to use explicit signaling - #62623
Merged
potiuk merged 1 commit intoMar 10, 2026
Merged
Conversation
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
force-pushed
the
DatabricksSqlHook-Timeout-Event
branch
from
February 28, 2026 13:12
45a9dfa to
dfe1ab6
Compare
Contributor
Author
|
Requesting review for this. |
potiuk
approved these changes
Mar 10, 2026
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>
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.
Description
This change refactors timeout handling in
DatabricksSqlHook.run()to replace implicit timeout detection based onTimer.is_alive()with explicit signaling using athreading.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 increate_timeout_thread()and updatesrun()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_threadand the associated timeout signal rather than relying onthreading.Timerbehavior.Backwards Compatibility
No changes to public APIs or behavior.