Reviewed-by: Aline Manera <alinefm(a)linux.vnet.ibm.com>
On 20/01/2015 06:45, lvroyce(a)linux.vnet.ibm.com wrote:
From: Royce Lv <lvroyce(a)linux.vnet.ibm.com>
url opened without close, fix it with contextlib
Signed-off-by: Royce Lv <lvroyce(a)linux.vnet.ibm.com>
---
src/kimchi/utils.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/kimchi/utils.py b/src/kimchi/utils.py
index 6acfa42..a279bc0 100644
--- a/src/kimchi/utils.py
+++ b/src/kimchi/utils.py
@@ -19,6 +19,7 @@
#
import cherrypy
+import contextlib
import grp
import os
import psutil
@@ -147,7 +148,8 @@ def check_url_path(path):
urlpath = parse_result.path
if not urlpath:
# Just a server, as with a repo.
- code = urllib2.urlopen(path).getcode()
+ with contextlib.closing(urllib2.urlopen(path)) as res:
+ code = res.getcode()
else:
# socket.gaierror could be raised,
# which is a child class of IOError