[elbe-devel] [PATCH] urllib2.urlopen: use 10 second connect timeout
John Ogness
john.ogness at linutronix.de
Fri Jul 22 15:27:15 CEST 2016
The default timeout for opening URL's is so long that the elbe client
will timeout before the elbe daemon. Thus the user is left with no
information about why the client timed out. With a smaller timeout
(this patch sets it to 10 seconds), the elbe client is informed that
there is a problem with the URL.
Signed-off-by: John Ogness <john.ogness at linutronix.de>
---
elbepack/elbexml.py | 2 +-
elbepack/pbuilder.py | 2 +-
elbepack/pkgutils.py | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/elbepack/elbexml.py b/elbepack/elbexml.py
index 8da97a5..95d0ac0 100644
--- a/elbepack/elbexml.py
+++ b/elbepack/elbexml.py
@@ -186,7 +186,7 @@ class ElbeXML(object):
usr, passwd = auth.split(':')
passman.add_password(None, u, usr, passwd)
try:
- fp = urllib2.urlopen (u)
+ fp = urllib2.urlopen(u, None, 10)
fp.close()
except urllib2.URLError:
raise ValidationError (["Repository %s can not be validated" % u])
diff --git a/elbepack/pbuilder.py b/elbepack/pbuilder.py
index b0830ab..9c1a4e6 100644
--- a/elbepack/pbuilder.py
+++ b/elbepack/pbuilder.py
@@ -80,7 +80,7 @@ def pbuilder_write_repo_hook (builddir, xml):
if url.has("key"):
key_url = url.text("key").strip()
key_url = key_url.replace("LOCALMACHINE", "10.0.2.2")
- key_conn = urllib2.urlopen( key_url )
+ key_conn = urllib2.urlopen(key_url, None, 10)
key_text = key_conn.read()
key_conn.close()
diff --git a/elbepack/pkgutils.py b/elbepack/pkgutils.py
index 5a75ba9..9590ecd 100644
--- a/elbepack/pkgutils.py
+++ b/elbepack/pkgutils.py
@@ -91,7 +91,7 @@ def get_initrd_pkg( prj, defs ):
def get_url ( arch, suite, target_pkg, mirror, comp='main' ):
try:
pack_url = "%s/dists/%s/%s/binary-%s/Packages" % (mirror.replace("LOCALMACHINE", "localhost"), suite, comp, arch)
- packages = urllib2.urlopen(pack_url)
+ packages = urllib2.urlopen(pack_url, None, 10)
packages = packages.readlines()
packages = filter( lambda x: x.startswith( "Filename" ), packages )
--
1.7.10.4
More information about the elbe-devel
mailing list