]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-45351, asyncio: Enhance echo server example, print all addresses (GH-28828)
authorOlaf van der Spek <olafvdspek@gmail.com>
Mon, 11 Oct 2021 18:54:44 +0000 (20:54 +0200)
committerGitHub <noreply@github.com>
Mon, 11 Oct 2021 18:54:44 +0000 (20:54 +0200)
Doc/library/asyncio-stream.rst

index b3e229c24f07d1078110f240d13299ab17b5400e..95a8e4649beede07dca948eada56cd6099e2caea 100644 (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()