Re-added close_conn connection on SFTPHook and get_conn should return SFTPClient instead of context managed connection#47217
Merged
potiuk merged 9 commits intoapache:mainfrom Feb 28, 2025
Conversation
…tead of context manager for backward compatibility
…egated method use the context manager which take care of closing the connection
This was referenced Feb 28, 2025
…thod anymore and test this behaviour
potiuk
approved these changes
Feb 28, 2025
Member
|
nice! thanks! |
eladkal
approved these changes
Feb 28, 2025
Contributor
Author
|
I've called the context managed connection get_sftp_conn, but I'm not happy with that name so I asked ChatGPT what would be an appropriate name for the context managed connection method: Option 1: connect() ✅ Simple and intuitive Option 2: get_managed_conn() ✅ Clearly indicates that it manages the connection lifecycle Option 3: use_conn() ✅ Short and easy to read What do you guys think? I would tend to choose option 2 or 3, as 3 could already be used I think and is confusing in my opinion. |
Member
|
2 is good |
67 tasks
nailo2c
pushed a commit
to nailo2c/airflow
that referenced
this pull request
Apr 4, 2025
… SFTPClient instead of context managed connection (apache#47217) * fix: SFTPHook.get_conn method should return SFTPClient connection instead of context manager for backward compatibility * fix: SFTPSensor doesn't need to call the close_conn method as the delegated method use the context manager which take care of closing the connection * refactor: Make sure SFTPSensor doesn't need to call the close_conn method anymore and test this behaviour * refactor: Renamed get_sftp_conn method of SFTPHook to use_conn * refactor: Renamed use_conn method of SFTPHook to get_managed_conn --------- Co-authored-by: David Blain <david.blain@infrabel.be>
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.
closes: #47129
closes: #47201
^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named
{pr_number}.significant.rstor{issue_number}.significant.rst, in newsfragments.