Issue #21038: Use monotonic clock to compute timeout, not the system clock

This commit is contained in:
Victor Stinner 2014-03-25 12:50:50 +01:00
parent 6f20b7c473
commit b60ac7acfb
1 changed files with 8 additions and 8 deletions

View File

@ -163,9 +163,9 @@ class TestEPoll(unittest.TestCase):
ep.register(client.fileno(), ep.register(client.fileno(),
select.EPOLLIN | select.EPOLLOUT | select.EPOLLET) select.EPOLLIN | select.EPOLLOUT | select.EPOLLET)
now = time.time() now = time.monotonic()
events = ep.poll(1, 4) events = ep.poll(1, 4)
then = time.time() then = time.monotonic()
self.assertFalse(then - now > 0.1, then - now) self.assertFalse(then - now > 0.1, then - now)
events.sort() events.sort()
@ -181,9 +181,9 @@ class TestEPoll(unittest.TestCase):
client.send(b"Hello!") client.send(b"Hello!")
server.send(b"world!!!") server.send(b"world!!!")
now = time.time() now = time.monotonic()
events = ep.poll(1, 4) events = ep.poll(1, 4)
then = time.time() then = time.monotonic()
self.assertFalse(then - now > 0.01) self.assertFalse(then - now > 0.01)
events.sort() events.sort()
@ -195,9 +195,9 @@ class TestEPoll(unittest.TestCase):
ep.unregister(client.fileno()) ep.unregister(client.fileno())
ep.modify(server.fileno(), select.EPOLLOUT) ep.modify(server.fileno(), select.EPOLLOUT)
now = time.time() now = time.monotonic()
events = ep.poll(1, 4) events = ep.poll(1, 4)
then = time.time() then = time.monotonic()
self.assertFalse(then - now > 0.01) self.assertFalse(then - now > 0.01)
expected = [(server.fileno(), select.EPOLLOUT)] expected = [(server.fileno(), select.EPOLLOUT)]
@ -214,9 +214,9 @@ class TestEPoll(unittest.TestCase):
ep = select.epoll(16) ep = select.epoll(16)
ep.register(server) ep.register(server)
now = time.time() now = time.monotonic()
events = ep.poll(1, 4) events = ep.poll(1, 4)
then = time.time() then = time.monotonic()
self.assertFalse(then - now > 0.01) self.assertFalse(then - now > 0.01)
server.close() server.close()