You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/08/10 07:53:41 UTC

[GitHub] [airflow] uranusjr commented on a change in pull request #17528: Ignores exception raised during closing SSH connection

uranusjr commented on a change in pull request #17528:
URL: https://github.com/apache/airflow/pull/17528#discussion_r685779664



##########
File path: airflow/providers/ssh/operators/ssh.py
##########
@@ -149,7 +149,13 @@ def execute(self, context) -> Union[bytes, str, bool]:
                         and not stdout.channel.recv_ready()
                     ):
                         stdout.channel.shutdown_read()
-                        stdout.channel.close()
+                        try:
+                            stdout.channel.close()
+                        except Exception as e:
+                            # there is a race that when shutdown_read has been called and when
+                            # you try to close the connection, the socket is already closed
+                            # We should ignore such errors (but we should log them with warning)
+                            self.log.warning("Ignoring exception on close: ", e)

Review comment:
       ```suggestion
                           except Exception:
                               # there is a race that when shutdown_read has been called and when
                               # you try to close the connection, the socket is already closed
                               # We should ignore such errors (but we should log them with warning)
                               self.log.warning("Ignoring exception on close", exc_info=True)
   ```
   
   I think this can catch more context




-- 
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-unsubscribe@airflow.apache.org

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