]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-45351, asyncio: Enhance echo server example, print all addresses (GH-28828)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 11 Oct 2021 19:34:51 +0000 (12:34 -0700)
committerGitHub <noreply@github.com>
Mon, 11 Oct 2021 19:34:51 +0000 (12:34 -0700)
(cherry picked from commit 659812b451aefe1f0e5f83540296519a5fb8f313)

Co-authored-by: Olaf van der Spek <olafvdspek@gmail.com>
Doc/library/asyncio-stream.rst

index 714de8d41a3503cfde0c4131d9983c32932f7e5c..bf431cfb8a410a66de87d836d17318dcbbb21f0f 100644 (file)
@@ -373,8 +373,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()