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:
@@ -31,7 +31,6 @@ from eventlet.hubs.poll import READ, WRITE
|
|||||||
# are identical in value to the poll constants
|
# are identical in value to the poll constants
|
||||||
|
|
||||||
class Hub(poll.Hub):
|
class Hub(poll.Hub):
|
||||||
WAIT_MULTIPLIER = 1.0 # epoll.poll's timeout is measured in seconds
|
|
||||||
def __init__(self, clock=time.time):
|
def __init__(self, clock=time.time):
|
||||||
BaseHub.__init__(self, clock)
|
BaseHub.__init__(self, clock)
|
||||||
self.poll = epoll()
|
self.poll = epoll()
|
||||||
@@ -51,3 +50,6 @@ class Hub(poll.Hub):
|
|||||||
else:
|
else:
|
||||||
self.register(fileno, new=False)
|
self.register(fileno, new=False)
|
||||||
return listener
|
return listener
|
||||||
|
|
||||||
|
def do_poll(self, seconds):
|
||||||
|
return self.poll.poll(seconds)
|
||||||
|
@@ -13,8 +13,6 @@ READ_MASK = select.POLLIN | select.POLLPRI
|
|||||||
WRITE_MASK = select.POLLOUT
|
WRITE_MASK = select.POLLOUT
|
||||||
|
|
||||||
class Hub(BaseHub):
|
class Hub(BaseHub):
|
||||||
WAIT_MULTIPLIER=1000.0 # poll.poll's timeout is measured in milliseconds
|
|
||||||
|
|
||||||
def __init__(self, clock=time.time):
|
def __init__(self, clock=time.time):
|
||||||
super(Hub, self).__init__(clock)
|
super(Hub, self).__init__(clock)
|
||||||
self.poll = select.poll()
|
self.poll = select.poll()
|
||||||
@@ -64,6 +62,10 @@ class Hub(BaseHub):
|
|||||||
# already removed/invalid
|
# already removed/invalid
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def do_poll(self, seconds):
|
||||||
|
# poll.poll expects integral milliseconds
|
||||||
|
return self.poll.poll(int(seconds * 1000.0))
|
||||||
|
|
||||||
def wait(self, seconds=None):
|
def wait(self, seconds=None):
|
||||||
readers = self.listeners[READ]
|
readers = self.listeners[READ]
|
||||||
writers = self.listeners[WRITE]
|
writers = self.listeners[WRITE]
|
||||||
@@ -73,7 +75,7 @@ class Hub(BaseHub):
|
|||||||
sleep(seconds)
|
sleep(seconds)
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
presult = self.poll.poll(int(seconds * self.WAIT_MULTIPLIER))
|
presult = self.do_poll(seconds)
|
||||||
except select.error, e:
|
except select.error, e:
|
||||||
if get_errno(e) == errno.EINTR:
|
if get_errno(e) == errno.EINTR:
|
||||||
return
|
return
|
||||||
|
Reference in New Issue
Block a user