Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.11] gh-102795: Fix use of poll in test_epoll's test_control_and_wait (GH-102796) #104173

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 11 additions & 4 deletions Lib/test/test_epoll.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
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")
Expand Down Expand Up @@ -186,10 +187,16 @@ def test_control_and_wait(self):
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)]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fix use of poll in test_epoll's test_control_and_wait