summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2010-12-31 00:51:24 -0800
committerZac Medico <zmedico@gentoo.org>2010-12-31 01:01:59 -0800
commita16356ce084f9bc13c6796de641581b7e14d69b1 (patch)
tree783f791db29f26b2ee6ea6ae8ea6e9cad2c2f85a
parent1ceeddf36574b9019258f3c3d4b08739e9e32d7a (diff)
downloadportage-a16356ce084f9bc13c6796de641581b7e14d69b1.tar.gz
portage-a16356ce084f9bc13c6796de641581b7e14d69b1.tar.bz2
portage-a16356ce084f9bc13c6796de641581b7e14d69b1.zip
bintree: add timeout for closing binhost connv2.1.9.27
Hopefully this solves bug #350139.
-rw-r--r--pym/portage/dbapi/bintree.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py
index 46f6509a7..55118a285 100644
--- a/pym/portage/dbapi/bintree.py
+++ b/pym/portage/dbapi/bintree.py
@@ -23,7 +23,7 @@ from portage.cache.mappings import slot_dict_class
from portage.const import CACHE_PATH
from portage.dbapi.virtual import fakedbapi
from portage.dep import Atom, use_reduce, paren_enclose
-from portage.exception import InvalidPackageName, \
+from portage.exception import AlarmSignal, InvalidPackageName, \
PermissionDenied, PortageException
from portage.localization import _
from portage import _movefile
@@ -806,7 +806,18 @@ class binarytree(object):
rmt_idx.readBody(f_dec)
pkgindex = rmt_idx
finally:
- f.close()
+ # Timeout after 5 seconds, in case close() blocks
+ # indefinitely (see bug #350139).
+ try:
+ try:
+ AlarmSignal.register(5)
+ f.close()
+ finally:
+ AlarmSignal.unregister()
+ except AlarmSignal:
+ writemsg("\n\n!!! %s\n" % \
+ _("Timed out while closing connection to binhost"),
+ noiselevel=-1)
except EnvironmentError as e:
writemsg(_("\n\n!!! Error fetching binhost package" \
" info from '%s'\n") % base_url)