mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
bpo-41317: Remove reader on cancellation in asyncio.loop.sock_accept() (#21595)
This commit is contained in:
parent
680254a8dc
commit
0dd98c2d00
3 changed files with 27 additions and 7 deletions
|
@ -415,6 +415,25 @@ class BaseSockTestsMixin:
|
|||
conn.close()
|
||||
listener.close()
|
||||
|
||||
def test_cancel_sock_accept(self):
|
||||
listener = socket.socket()
|
||||
listener.setblocking(False)
|
||||
listener.bind(('127.0.0.1', 0))
|
||||
listener.listen(1)
|
||||
sockaddr = listener.getsockname()
|
||||
f = asyncio.wait_for(self.loop.sock_accept(listener), 0.1)
|
||||
with self.assertRaises(asyncio.TimeoutError):
|
||||
self.loop.run_until_complete(f)
|
||||
|
||||
listener.close()
|
||||
client = socket.socket()
|
||||
client.setblocking(False)
|
||||
f = self.loop.sock_connect(client, sockaddr)
|
||||
with self.assertRaises(ConnectionRefusedError):
|
||||
self.loop.run_until_complete(f)
|
||||
|
||||
client.close()
|
||||
|
||||
def test_create_connection_sock(self):
|
||||
with test_utils.run_test_server() as httpd:
|
||||
sock = None
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue