Skip to content

Commit 3945e9a

Browse files
committed
Update test_epoll.py from CPython v3.12.0
1 parent ad3f0ae commit 3945e9a

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

Lib/test/test_epoll.py

+11-4
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import socket
2828
import time
2929
import unittest
30+
from test import support
3031

3132
if not hasattr(select, "epoll"):
3233
raise unittest.SkipTest("test works only on Linux 2.6")
@@ -186,10 +187,16 @@ def test_control_and_wait(self):
186187
client.sendall(b"Hello!")
187188
server.sendall(b"world!!!")
188189

189-
now = time.monotonic()
190-
events = ep.poll(1.0, 4)
191-
then = time.monotonic()
192-
self.assertFalse(then - now > 0.01)
190+
# we might receive events one at a time, necessitating multiple calls to
191+
# poll
192+
events = []
193+
for _ in support.busy_retry(support.SHORT_TIMEOUT):
194+
now = time.monotonic()
195+
events += ep.poll(1.0, 4)
196+
then = time.monotonic()
197+
self.assertFalse(then - now > 0.01)
198+
if len(events) >= 2:
199+
break
193200

194201
expected = [(client.fileno(), select.EPOLLIN | select.EPOLLOUT),
195202
(server.fileno(), select.EPOLLIN | select.EPOLLOUT)]

0 commit comments

Comments
 (0)