You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "Qian Yu (Jira)" <ji...@apache.org> on 2020/02/14 01:04:00 UTC
[jira] [Created] (AIRFLOW-6800) SSHHook: Close file object when
reading ssh config
Qian Yu created AIRFLOW-6800:
--------------------------------
Summary: SSHHook: Close file object when reading ssh config
Key: AIRFLOW-6800
URL: https://issues.apache.org/jira/browse/AIRFLOW-6800
Project: Apache Airflow
Issue Type: Improvement
Components: hooks
Affects Versions: 1.10.9
Reporter: Qian Yu
Assignee: Qian Yu
This line of code in ssh/hooks.py is opening a file object without closing it in the scope where it is opened.
This causes unnecessary noise e.g. when py.test warns about unclosed file objects:
{code}
ResourceWarning: unclosed file <_io.TextIOWrapper name='/home/test/.ssh/config' mode='r' encoding='UTF-8'>
Exception ignored in: <_io.FileIO name='/home/test/.ssh/config' mode='rb' closefd=True>
{code}
Using context manager fixes this easily.
{code}
ssh_conf = paramiko.SSHConfig()
ssh_conf.parse(open(user_ssh_config_filename))
host_info = ssh_conf.lookup(self.remote_host)
{code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)