Port to eventlet 0.14

This commit is contained in:
Victor Stinner
2014-11-19 15:08:56 +01:00
parent ce52526090
commit ed48af24ac
2 changed files with 8 additions and 2 deletions

2
README
View File

@@ -16,7 +16,7 @@ Installation
Requirements:
- eventlet (it was tested with eventlet 0.15)
- eventlet 0.14 or newer
- asyncio or trollius:
* Python 3.4 and newer: asyncio is now part of the stdlib

View File

@@ -43,6 +43,9 @@ threading = eventlet.patcher.original('threading')
_READ = eventlet.hubs.hub.READ
_WRITE = eventlet.hubs.hub.WRITE
# Eventlet 0.15 or newer?
_EVENTLET15 = hasattr(eventlet.hubs.hub.noop, 'mark_as_closed')
# tulip >= 3.4.2 and trollius >= 1.0.2 implement an optimization
# for cancelled timer handles
_OPTIMIZE_CANCELLED_TIMERS = hasattr(asyncio.TimerHandle, '_scheduled')
@@ -398,7 +401,10 @@ class EventLoop(BaseEventLoop):
fd = selectors._fileobj_to_fd(fd)
def func(fd):
return callback(*args)
self._hub.add(event_type, fd, func, self._throwback, None)
if _EVENTLET15:
self._hub.add(event_type, fd, func, self._throwback, None)
else:
self._hub.add(event_type, fd, func)
def add_reader(self, fd, callback, *args):
self._add_fd(_READ, fd, callback, args)