diff options
author | Zac Medico <zmedico@gentoo.org> | 2009-10-18 03:20:48 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2009-10-18 03:20:48 +0000 |
commit | 34ef3eed59e84781fe6e8d0f20a5859647740312 (patch) | |
tree | 540d8e3c2abad9e967e5b5ebcb11db63883440f7 | |
parent | bab9dee99a7e36479faf581669e087cf2ca02fe3 (diff) | |
download | portage-34ef3eed59e84781fe6e8d0f20a5859647740312.tar.gz portage-34ef3eed59e84781fe6e8d0f20a5859647740312.tar.bz2 portage-34ef3eed59e84781fe6e8d0f20a5859647740312.zip |
Only call _test_pty_eof() on Linux, since it seems to hang on most other
kernels. This should fix the hang reported on FreeBSD here:
http://archives.gentoo.org/gentoo-alt/msg_d81c5e8c6dd6849312ecb048feb41c5b.xml
(trunk r14606)
svn path=/main/branches/2.1.7/; revision=14636
-rw-r--r-- | pym/portage/__init__.py | 23 | ||||
-rw-r--r-- | pym/portage/tests/ebuild/test_pty_eof.py | 9 |
2 files changed, 25 insertions, 7 deletions
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index 08d8f4152..54d45dabc 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -3777,6 +3777,15 @@ class config(object): keys = __iter__ items = iteritems +def _can_test_pty_eof(): + """ + The _test_pty_eof() function seems to hang on most + kernels other than Linux. + @rtype: bool + @returns: True if _test_pty_eof() won't hang, False otherwise. + """ + return platform.system() in ("Linux",) + def _test_pty_eof(): """ Returns True if this issues is fixed for the currently @@ -3861,9 +3870,13 @@ def _test_pty_eof(): return test_string == ''.join(data) -# In some cases, openpty can be slow when it fails. Therefore, -# stop trying to use it after the first failure. -if platform.system() not in ["FreeBSD", "Linux"]: +# If _test_pty_eof() can't be used for runtime detection of +# http://bugs.python.org/issue5380, openpty can't safely be used +# unless we can guarantee that the current version of python has +# been fixed (affects all current versions of python3). When +# this issue is fixed in python3, we can add another sys.hexversion +# conditional to enable openpty support in the fixed versions. +if sys.hexversion >= 0x3000000 and not _can_test_pty_eof(): # Disable the use of openpty on Solaris as it seems Python's openpty # implementation doesn't play nice on Solaris with Portage's # behaviour causing hangs/deadlocks. @@ -3880,6 +3893,10 @@ else: _disable_openpty = False _tested_pty = False +if not _can_test_pty_eof(): + # Skip _test_pty_eof() on systems where it hangs. + _tested_pty = True + def _create_pty_or_pipe(copy_term_size=None): """ Try to create a pty and if then fails then create a normal diff --git a/pym/portage/tests/ebuild/test_pty_eof.py b/pym/portage/tests/ebuild/test_pty_eof.py index 0dd1e8506..31a5df4aa 100644 --- a/pym/portage/tests/ebuild/test_pty_eof.py +++ b/pym/portage/tests/ebuild/test_pty_eof.py @@ -13,7 +13,8 @@ class PtyEofTestCase(TestCase): # Since it might not be fixed, mark as todo. self.todo = True # The result is only valid if openpty does not raise EnvironmentError. - try: - self.assertEqual(portage._test_pty_eof(), True) - except EnvironmentError: - pass + if portage._can_test_pty_eof(): + try: + self.assertEqual(portage._test_pty_eof(), True) + except EnvironmentError: + pass |