Code was correct, but only for epoll. Glad we have these tests.

This commit is contained in:
Ryan Williams
2010-01-18 23:26:16 -08:00
parent 52e1522af4
commit 047b214fe9

View File

@@ -8,6 +8,7 @@ except ImportError, e:
import time import time
from eventlet.hubs.hub import BaseHub from eventlet.hubs.hub import BaseHub
from eventlet.hubs import poll from eventlet.hubs import poll
from eventlet.hubs.poll import READ, WRITE
# NOTE: we rely on the fact that the epoll flag constants # NOTE: we rely on the fact that the epoll flag constants
# are identical in value to the poll constants # are identical in value to the poll constants
@@ -22,3 +23,12 @@ class Hub(poll.Hub):
self.modify = self.poll.modify self.modify = self.poll.modify
except AttributeError: except AttributeError:
self.modify = self.poll.register 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)
if not oldlisteners:
# Means we've added a new listener
self.register(fileno, new=True)
return listener