[Kimchi-devel] [kimchi-devel][PATCH 4/7] close fh after iso scanning

Aline Manera alinefm at linux.vnet.ibm.com
Thu Jan 22 17:41:25 UTC 2015


Reviewed-by: Aline Manera <alinefm at linux.vnet.ibm.com>

On 20/01/2015 06:45, lvroyce at linux.vnet.ibm.com wrote:
> From: Royce Lv <lvroyce at linux.vnet.ibm.com>
>
> When check remote iso, we open an url without close it.
> fix this using contextlib.
>
> Signed-off-by: Royce Lv <lvroyce at linux.vnet.ibm.com>
> ---
>   src/kimchi/isoinfo.py | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/src/kimchi/isoinfo.py b/src/kimchi/isoinfo.py
> index fb87949..34e526c 100644
> --- a/src/kimchi/isoinfo.py
> +++ b/src/kimchi/isoinfo.py
> @@ -17,6 +17,7 @@
>   # License along with this library; if not, write to the Free Software
>   # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
>
> +import contextlib
>   import glob
>   import platform
>   import os
> @@ -414,8 +415,8 @@ lang=en#!/wiki/W51a7ffcf4dfd_4b40_9d82_446ebc23c550/page/PowerLinux\
>               request = urllib2.Request(self.path)
>               range_header = "bytes=%d-%d" % (offset, offset + size - 1)
>               request.add_header("range", range_header)
> -            response = urllib2.urlopen(request)
> -            data = response.read()
> +            with contextlib.closing(urllib2.urlopen(request)) as response:
> +                data = response.read()
>           else:
>               with open(self.path) as fd:
>                   fd.seek(offset)




More information about the Kimchi-devel mailing list