eladkal closed pull request #4325: [AIRFLOW-3528] handle socket exception with 
SFTPOperator
URL: https://github.com/apache/incubator-airflow/pull/4325
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/airflow/contrib/operators/sftp_operator.py 
b/airflow/contrib/operators/sftp_operator.py
index 117bc55a8c..d364772c83 100644
--- a/airflow/contrib/operators/sftp_operator.py
+++ b/airflow/contrib/operators/sftp_operator.py
@@ -122,7 +122,11 @@ def execute(self, context):
                 self.ssh_hook.remote_host = self.remote_host
 
             with self.ssh_hook.get_conn() as ssh_client:
-                sftp_client = ssh_client.open_sftp()
+                try:
+                    sftp_client = ssh_client.open_sftp()
+                except OSError as e:
+                    raise AirflowException("Error while connecting client, 
error: {0}"
+                                           .format(str(e)))
                 if self.operation.lower() == SFTPOperation.GET:
                     local_folder = os.path.dirname(self.local_filepath)
                     if self.create_intermediate_dirs:


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to