Added do_poll method to poll hubs so that the APis get handed the appropriate flavor of timeout. Thanks to redbo for tracking this down.

This commit is contained in:
Ryan Williams
2010-04-19 23:53:07 -07:00
parent 54e0280e0a
commit bb849583c0
2 changed files with 8 additions and 4 deletions

View File

@@ -31,7 +31,6 @@ from eventlet.hubs.poll import READ, WRITE
# are identical in value to the poll constants
class Hub(poll.Hub):
WAIT_MULTIPLIER = 1.0 # epoll.poll's timeout is measured in seconds
def __init__(self, clock=time.time):
BaseHub.__init__(self, clock)
self.poll = epoll()
@@ -51,3 +50,6 @@ class Hub(poll.Hub):
else:
self.register(fileno, new=False)
return listener
def do_poll(self, seconds):
return self.poll.poll(seconds)

View File

@@ -13,8 +13,6 @@ READ_MASK = select.POLLIN | select.POLLPRI
WRITE_MASK = select.POLLOUT
class Hub(BaseHub):
WAIT_MULTIPLIER=1000.0 # poll.poll's timeout is measured in milliseconds
def __init__(self, clock=time.time):
super(Hub, self).__init__(clock)
self.poll = select.poll()
@@ -64,6 +62,10 @@ class Hub(BaseHub):
# already removed/invalid
pass
def do_poll(self, seconds):
# poll.poll expects integral milliseconds
return self.poll.poll(int(seconds * 1000.0))
def wait(self, seconds=None):
readers = self.listeners[READ]
writers = self.listeners[WRITE]
@@ -73,7 +75,7 @@ class Hub(BaseHub):
sleep(seconds)
return
try:
presult = self.poll.poll(int(seconds * self.WAIT_MULTIPLIER))
presult = self.do_poll(seconds)
except select.error, e:
if get_errno(e) == errno.EINTR:
return