mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-28 18:59:04 +08:00
Update test_epoll.py from CPython v3.12.0
This commit is contained in:
1 parent
ad3f0aecaf
commit
3945e9a4ed
1 file changed
+11
-4
Vendored
+11
-4
@@ -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)]
|
||||
|
||||
Reference in new issue
Block a user