summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2012-02-15 01:32:40 -0800
committerZac Medico <zmedico@gentoo.org>2012-02-15 01:32:40 -0800
commita979c180b5c8ce98231d7e3c20f2d38d272f7b45 (patch)
tree9565a8fe1eba43016e81c5509954f5ae1f092550
parenta16c54c0d5b891655bce89e5779e6b9221131ba7 (diff)
downloadportage-a979c180b5c8ce98231d7e3c20f2d38d272f7b45.tar.gz
portage-a979c180b5c8ce98231d7e3c20f2d38d272f7b45.tar.bz2
portage-a979c180b5c8ce98231d7e3c20f2d38d272f7b45.zip
get_open_fds: handle EAGAIN for PyPy 1.8
-rw-r--r--pym/portage/process.py16
1 files changed, 15 insertions, 1 deletions
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)