[
https://issues.apache.org/jira/browse/AIRFLOW-6800?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Kamil Bregula closed AIRFLOW-6800.
----------------------------------
Fix Version/s: 1.10.10
Resolution: Fixed
> 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
> Priority: Trivial
> Fix For: 1.10.10
>
>
> 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)