mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
bpo-35934: Add socket.create_server() utility function (GH-11784)
This commit is contained in:
parent
58721a9030
commit
eb7e29f2a9
17 changed files with 289 additions and 88 deletions
|
@ -592,8 +592,7 @@ class StreamTests(test_utils.TestCase):
|
|||
await client_writer.wait_closed()
|
||||
|
||||
def start(self):
|
||||
sock = socket.socket()
|
||||
sock.bind(('127.0.0.1', 0))
|
||||
sock = socket.create_server(('127.0.0.1', 0))
|
||||
self.server = self.loop.run_until_complete(
|
||||
asyncio.start_server(self.handle_client,
|
||||
sock=sock,
|
||||
|
@ -605,8 +604,7 @@ class StreamTests(test_utils.TestCase):
|
|||
client_writer))
|
||||
|
||||
def start_callback(self):
|
||||
sock = socket.socket()
|
||||
sock.bind(('127.0.0.1', 0))
|
||||
sock = socket.create_server(('127.0.0.1', 0))
|
||||
addr = sock.getsockname()
|
||||
sock.close()
|
||||
self.server = self.loop.run_until_complete(
|
||||
|
@ -796,10 +794,7 @@ os.close(fd)
|
|||
|
||||
def server():
|
||||
# Runs in a separate thread.
|
||||
sock = socket.socket()
|
||||
with sock:
|
||||
sock.bind(('localhost', 0))
|
||||
sock.listen(1)
|
||||
with socket.create_server(('localhost', 0)) as sock:
|
||||
addr = sock.getsockname()
|
||||
q.put(addr)
|
||||
clt, _ = sock.accept()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue