summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2007-10-13 19:04:42 +0000
committerZac Medico <zmedico@gentoo.org>2007-10-13 19:04:42 +0000
commit9abd1e4a4453722e02d1bf5ee8ff37d9072101ad (patch)
tree6342e065cab483750b23df17860449db804f308d
parentec42472010570e1ffa5667a4cb724ecd605fd95f (diff)
downloadportage-9abd1e4a4453722e02d1bf5ee8ff37d9072101ad.tar.gz
portage-9abd1e4a4453722e02d1bf5ee8ff37d9072101ad.tar.bz2
portage-9abd1e4a4453722e02d1bf5ee8ff37d9072101ad.zip
In some cases, openpty can be slow when it fails. Therefore,
stop trying to use it after the first failure. svn path=/main/trunk/; revision=8119
-rw-r--r--pym/portage/__init__.py23
1 files changed, 16 insertions, 7 deletions
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index b99805d0b..cf56a5c4a 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -2504,6 +2504,10 @@ class config(object):
pass
return self._selinux_enabled
+# In some cases, openpty can be slow when it fails. Therefore,
+# stop trying to use it after the first failure.
+_disable_openpty = False
+
# XXX This would be to replace getstatusoutput completely.
# XXX Issue: cannot block execution. Deadlock condition.
def spawn(mystring, mysettings, debug=0, free=0, droppriv=0, sesandbox=0, fakeroot=0, **keywords):
@@ -2578,14 +2582,19 @@ def spawn(mystring, mysettings, debug=0, free=0, droppriv=0, sesandbox=0, fakero
del keywords["logfile"]
if 1 not in fd_pipes or 2 not in fd_pipes:
raise ValueError(fd_pipes)
- from pty import openpty
- try:
- master_fd, slave_fd = openpty()
- got_pty = True
- except EnvironmentError, e:
- writemsg("openpty failed: '%s'\n" % str(e), noiselevel=1)
- del e
+ global _disable_openpty
+ if _disable_openpty:
master_fd, slave_fd = os.pipe()
+ else:
+ from pty import openpty
+ try:
+ master_fd, slave_fd = openpty()
+ got_pty = True
+ except EnvironmentError, e:
+ _disable_openpty = True
+ writemsg("openpty failed: '%s'\n" % str(e), noiselevel=1)
+ del e
+ master_fd, slave_fd = os.pipe()
# We must set non-blocking mode before we close the slave_fd
# since otherwise the fcntl call can fail on FreeBSD (the child