pankajkoti commented on code in PR #40022:
URL: https://github.com/apache/airflow/pull/40022#discussion_r1631159143


##########
airflow/providers/sftp/hooks/sftp.py:
##########
@@ -558,13 +558,17 @@ async def get_mod_time(self, path: str) -> str:
 
         :param path: full path to the remote file
         """
-        ssh_conn = await self._get_conn()
-        sftp_client = await ssh_conn.start_sftp_client()
+        ssh_conn = None
         try:
+            ssh_conn = await self._get_conn()
+            sftp_client = await ssh_conn.start_sftp_client()
             ftp_mdtm = await sftp_client.stat(path)
             modified_time = ftp_mdtm.mtime
             mod_time = 
datetime.datetime.fromtimestamp(modified_time).strftime("%Y%m%d%H%M%S")  # 
type: ignore[arg-type]
             self.log.info("Found File %s last modified: %s", str(path), 
str(mod_time))
             return mod_time
         except asyncssh.SFTPNoSuchFile:
             raise AirflowException("No files matching")
+        finally:

Review Comment:
   okay, I will see if I can get that fixed in another PR. But until I get a 
chance to revisit, I think to better to have the fix out soon. I will merge the 
PR, thanks again for fixing this.



-- 
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: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to