Update test_epoll.py from CPython v3.12.0

This commit is contained in:
NakanoMiku committed 2023-11-30 21:06:09 +08:00
1 parent ad3f0aecaf
commit 3945e9a4ed
1 file changed
+11 -4
+11 -4
View File
@@ -27,6 +27,7 @@ import select
import socket
import time
import unittest
from test import support
if not hasattr(select, "epoll"):
raise unittest.SkipTest("test works only on Linux 2.6")
@@ -186,10 +187,16 @@ class TestEPoll(unittest.TestCase):
client.sendall(b"Hello!")
server.sendall(b"world!!!")
now = time.monotonic()
events = ep.poll(1.0, 4)
then = time.monotonic()
self.assertFalse(then - now > 0.01)
# we might receive events one at a time, necessitating multiple calls to
# poll
events = []
for _ in support.busy_retry(support.SHORT_TIMEOUT):
now = time.monotonic()
events += ep.poll(1.0, 4)
then = time.monotonic()
self.assertFalse(then - now > 0.01)
if len(events) >= 2:
break
expected = [(client.fileno(), select.EPOLLIN | select.EPOLLOUT),
(server.fileno(), select.EPOLLIN | select.EPOLLOUT)]