bpo-45351, asyncio: Enhance echo server example, print all addresses (GH-28828)

This commit is contained in:
Olaf van der Spek 2021-10-11 20:54:44 +02:00 • committed by GitHub
parent 560a79f94e
commit 659812b451
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -395,8 +395,8 @@ TCP echo server using the :func:`asyncio.start_server` function::
server = await asyncio.start_server(
handle_echo, '127.0.0.1', 8888)
addr = server.sockets[0].getsockname()
print(f'Serving on {addr}')
addrs = ', '.join(str(sock.getsockname()) for sock in server.sockets)
print(f'Serving on {addrs}')
async with server:
await server.serve_forever()