mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
bpo-22831: Use "with" to avoid possible fd leaks in tests (part 2). (GH-10929)
This commit is contained in:
parent
9e4861f523
commit
5b10b98247
25 changed files with 253 additions and 312 deletions
|
|
@ -143,18 +143,17 @@ class TestEPoll(unittest.TestCase):
|
|||
def test_fromfd(self):
|
||||
server, client = self._connected_pair()
|
||||
|
||||
ep = select.epoll(2)
|
||||
ep2 = select.epoll.fromfd(ep.fileno())
|
||||
with select.epoll(2) as ep:
|
||||
ep2 = select.epoll.fromfd(ep.fileno())
|
||||
|
||||
ep2.register(server.fileno(), select.EPOLLIN | select.EPOLLOUT)
|
||||
ep2.register(client.fileno(), select.EPOLLIN | select.EPOLLOUT)
|
||||
ep2.register(server.fileno(), select.EPOLLIN | select.EPOLLOUT)
|
||||
ep2.register(client.fileno(), select.EPOLLIN | select.EPOLLOUT)
|
||||
|
||||
events = ep.poll(1, 4)
|
||||
events2 = ep2.poll(0.9, 4)
|
||||
self.assertEqual(len(events), 2)
|
||||
self.assertEqual(len(events2), 2)
|
||||
events = ep.poll(1, 4)
|
||||
events2 = ep2.poll(0.9, 4)
|
||||
self.assertEqual(len(events), 2)
|
||||
self.assertEqual(len(events2), 2)
|
||||
|
||||
ep.close()
|
||||
try:
|
||||
ep2.poll(1, 4)
|
||||
except OSError as e:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue