Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b60ac7a

Browse files
committed
Issue #21038: Use monotonic clock to compute timeout, not the system clock
1 parent 6f20b7c commit b60ac7a

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

Lib/test/test_epoll.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,9 @@ def test_control_and_wait(self):
163163
ep.register(client.fileno(),
164164
select.EPOLLIN | select.EPOLLOUT | select.EPOLLET)
165165

166-
now = time.time()
166+
now = time.monotonic()
167167
events = ep.poll(1, 4)
168-
then = time.time()
168+
then = time.monotonic()
169169
self.assertFalse(then - now > 0.1, then - now)
170170

171171
events.sort()
@@ -181,9 +181,9 @@ def test_control_and_wait(self):
181181
client.send(b"Hello!")
182182
server.send(b"world!!!")
183183

184-
now = time.time()
184+
now = time.monotonic()
185185
events = ep.poll(1, 4)
186-
then = time.time()
186+
then = time.monotonic()
187187
self.assertFalse(then - now > 0.01)
188188

189189
events.sort()
@@ -195,9 +195,9 @@ def test_control_and_wait(self):
195195

196196
ep.unregister(client.fileno())
197197
ep.modify(server.fileno(), select.EPOLLOUT)
198-
now = time.time()
198+
now = time.monotonic()
199199
events = ep.poll(1, 4)
200-
then = time.time()
200+
then = time.monotonic()
201201
self.assertFalse(then - now > 0.01)
202202

203203
expected = [(server.fileno(), select.EPOLLOUT)]
@@ -214,9 +214,9 @@ def test_unregister_closed(self):
214214
ep = select.epoll(16)
215215
ep.register(server)
216216

217-
now = time.time()
217+
now = time.monotonic()
218218
events = ep.poll(1, 4)
219-
then = time.time()
219+
then = time.monotonic()
220220
self.assertFalse(then - now > 0.01)
221221

222222
server.close()

0 commit comments

Comments
 (0)