/usr/lib/python2.7/dist-packages/eventlet/hubs/epolls.py is in python-eventlet 0.13.0-2.
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 58 59 60 61 | import errno
from eventlet.support import get_errno
from eventlet import patcher
time = patcher.original('time')
select = patcher.original("select")
if hasattr(select, 'epoll'):
epoll = select.epoll
else:
try:
# http://pypi.python.org/pypi/select26/
from select26 import epoll
except ImportError:
try:
import epoll as _epoll_mod
except ImportError:
raise ImportError(
"No epoll implementation found in select module or PYTHONPATH")
else:
if hasattr(_epoll_mod, 'poll'):
epoll = _epoll_mod.poll
else:
raise ImportError(
"You have an old, buggy epoll module in PYTHONPATH."
" Install http://pypi.python.org/pypi/python-epoll/"
" NOT http://pypi.python.org/pypi/pyepoll/. "
" easy_install pyepoll installs the wrong version.")
from eventlet.hubs.hub import BaseHub
from eventlet.hubs import poll
from eventlet.hubs.poll import READ, WRITE
# NOTE: we rely on the fact that the epoll flag constants
# are identical in value to the poll constants
class Hub(poll.Hub):
def __init__(self, clock=time.time):
BaseHub.__init__(self, clock)
self.poll = epoll()
try:
# modify is required by select.epoll
self.modify = self.poll.modify
except AttributeError:
self.modify = self.poll.register
def add(self, evtype, fileno, cb):
oldlisteners = bool(self.listeners[READ].get(fileno) or
self.listeners[WRITE].get(fileno))
listener = BaseHub.add(self, evtype, fileno, cb)
try:
if not oldlisteners:
# Means we've added a new listener
self.register(fileno, new=True)
else:
self.register(fileno, new=False)
except IOError, ex: # ignore EEXIST, #80
if get_errno(ex) != errno.EEXIST:
raise
return listener
def do_poll(self, seconds):
return self.poll.poll(seconds)
|