@@ -2902,7 +2902,9 @@ application on specific TCP or Unix socket, e.g.::
29022902
29032903 :param str host: HOST to listen on, all interfaces if ``None `` (default).
29042904
2905- :param int port: PORT to listed on, ``8080 `` if ``None `` (default).
2905+ :param int port: PORT to listen on, ``8080 `` if ``None `` (default).
2906+ Use ``0 `` to let the OS assign a free ephemeral port
2907+ (see :attr: `port `).
29062908
29072909 :param float shutdown_timeout: a timeout used for both waiting on pending
29082910 tasks before application shutdown and for
@@ -2935,20 +2937,6 @@ application on specific TCP or Unix socket, e.g.::
29352937 Read-only. The actual port number the server is bound to, only
29362938 guaranteed to be correct after the site has been started.
29372939
2938- To bind to a dynamic port, pass ``0 `` as the port number. The OS
2939- will assign a free port which can then be retrieved from this
2940- attribute::
2941-
2942- app = web.Application()
2943- runner = web.AppRunner(app)
2944- await runner.setup()
2945- site = web.TCPSite(runner, 'localhost', 0)
2946- await site.start()
2947-
2948- print(f"Server started on port {site.port}")
2949- while True:
2950- await asyncio.sleep(3600) # sleep forever
2951-
29522940
29532941.. class :: UnixSite(runner, path, *, \
29542942 shutdown_timeout=60.0, ssl_context=None, \
0 commit comments