From: Zac Medico Date: Wed, 15 Feb 2012 09:32:40 +0000 (-0800) Subject: get_open_fds: handle EAGAIN for PyPy 1.8 X-Git-Tag: v2.2.0_alpha87~31 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=a979c180b5c8ce98231d7e3c20f2d38d272f7b45;p=portage.git get_open_fds: handle EAGAIN for PyPy 1.8 --- diff --git a/pym/portage/process.py b/pym/portage/process.py index e7313abc3..febaf662e 100644 --- a/pym/portage/process.py +++ b/pym/portage/process.py @@ -1,9 +1,11 @@ # portage.py -- core Portage functionality -# Copyright 1998-2010 Gentoo Foundation +# Copyright 1998-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 import atexit +import errno +import platform import signal import sys import traceback @@ -32,6 +34,18 @@ if os.path.isdir("/proc/%i/fd" % os.getpid()): def get_open_fds(): return (int(fd) for fd in os.listdir("/proc/%i/fd" % os.getpid()) \ if fd.isdigit()) + + if platform.python_implementation() == 'PyPy': + # EAGAIN observed with PyPy 1.8. + _get_open_fds = get_open_fds + def get_open_fds(): + try: + return _get_open_fds() + except OSError as e: + if e.errno != errno.EAGAIN: + raise + return range(max_fd_limit) + else: def get_open_fds(): return range(max_fd_limit)