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/07/19 03:24:35 UTC

[GitHub] [airflow] uranusjr commented on issue #10874: SSHHook get_conn() does not re-use client

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


   > The right way of reusing a connection (even if you want to compose or subclass something) is to reuse HOOK not operator.
   
   The problem is `SSHHook` *also* does not reuse the underlying Paramiko connection, a new `paramiko.SSHClient` is created every time `SSHHook.get_conn()` is called, and it’s very non-obvious how that connection should be reused.
   
   ```python
   hook = SSHHook(...)
   
   client = hook.get_conn()
   
   # Does not reuse! A brand new connection is established.
   # Plus the previous connection is now dangling.
   client = hook.get_conn()
   ```
   
   But I don’t think there’s a good quick solution to the problem; `SSHHook` is fundamentally not designed to be reused. So this probably should be removed from good-first-issue and we need to properly re-design `SSHHook`’s interface to make it work.


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