/usr/share/pyshared/eventlet/hubs/selects.py is in python-eventlet 0.9.16-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | import sys
import errno
from eventlet import patcher
from eventlet.support import get_errno, clear_sys_exc_info
select = patcher.original('select')
time = patcher.original('time')
from eventlet.hubs.hub import BaseHub, READ, WRITE, noop
try:
BAD_SOCK = set((errno.EBADF, errno.WSAENOTSOCK))
except AttributeError:
BAD_SOCK = set((errno.EBADF,))
class Hub(BaseHub):
def _remove_bad_fds(self):
""" Iterate through fds, removing the ones that are bad per the
operating system.
"""
for fd in self.listeners[READ].keys() + self.listeners[WRITE].keys():
try:
select.select([fd], [], [], 0)
except select.error, e:
if get_errno(e) in BAD_SOCK:
self.remove_descriptor(fd)
def wait(self, seconds=None):
readers = self.listeners[READ]
writers = self.listeners[WRITE]
if not readers and not writers:
if seconds:
time.sleep(seconds)
return
try:
r, w, er = select.select(readers.keys(), writers.keys(), readers.keys() + writers.keys(), seconds)
except select.error, e:
if get_errno(e) == errno.EINTR:
return
elif get_errno(e) in BAD_SOCK:
self._remove_bad_fds()
return
else:
raise
for fileno in er:
readers.get(fileno, noop).cb(fileno)
writers.get(fileno, noop).cb(fileno)
for listeners, events in ((readers, r), (writers, w)):
for fileno in events:
try:
listeners.get(fileno, noop).cb(fileno)
except self.SYSTEM_EXCEPTIONS:
raise
except:
self.squelch_exception(fileno, sys.exc_info())
clear_sys_exc_info()
|