potiuk commented on issue #10874:
URL: https://github.com/apache/airflow/issues/10874#issuecomment-882501847


   @baolsen:
   
   | One option could be to refactor SSHOperator to isolate the "run an SSH 
command" part which can be reused by subclasses.
   
   Oh yeah Makes total sense. And (see below) it can be easily fixed to provide 
client caching in Hook
   
   @uranusjr :
   
   ```
   # Does not reuse! A brand new connection is established.
   # Plus the previous connection is now dangling.
   client = hook.get_conn()
   ```
   
   Yeah. Because SSHHook pretty much does not have its own methods so it was 
never a problem, I guess. It delegates everything to SSHClient. It is a Hook 
that on it's own is not even a thin wrapper around the SSHClient but delegates 
all the work to it. I think quick fixing it and caching the client should be 
two lines code (it happens in other operators):
   
   ```
   if self.client:
       return client
   ```


-- 
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]


Reply via email to