Christopher-Gentle opened a new issue, #39922:
URL: https://github.com/apache/airflow/issues/39922
### Apache Airflow Provider(s)
sftp
### Versions of Apache Airflow Providers
4.10.0
### Apache Airflow version
2.7.2
### Operating System
Amazon Linux
### Deployment
Amazon (AWS) MWAA
### Deployment details
_No response_
### What happened
While a fix was implemented for methods: list_directory, read_directory and
get_files_and_attrs_by_pattern; The fix was left off of the get_mod_time method.
`ssh_conn = await self._get_conn()
sftp_client = await ssh_conn.start_sftp_client()`
When a user tries to use the SFTPSensor operator, using path/newer_than, it
will open a connection and remain open.
### What you think should happen instead
Implement context/resource management in method get_mod_time for the
ssh_conn.
This will close the sftp-server on the remote host.
### How to reproduce
`sense_sftp_file = SFTPSensor(
task_id=f"sense_sftp_file",
sftp_conn_id="sftp_default_id",
path="/tmp/test.txt",
poke_interval=120,
newer_than="{{ (macros.datetime.utcnow() -
macros.timedelta(hours=24)) }}",
timeout=timedelta(hours=1),
deferrable=True,
)`
### Anything else
Anytime this operator is used with path and newer_than parameters.
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]