@@ -407,7 +407,7 @@ def serve(ws_handler, host=None, port=None, *,
407407
408408 :func:`serve` is a wrapper around the event loop's
409409 :meth:`~asyncio.BaseEventLoop.create_server` method. ``host``, ``port`` as
410- well as extra keyword arguments are passed to
410+ well as unknown keyword arguments are passed to
411411 :meth:`~asyncio.BaseEventLoop.create_server`.
412412
413413 For example, you can set the ``ssl`` keyword argument to a
@@ -441,6 +441,9 @@ def serve(ws_handler, host=None, port=None, *,
441441 logger.setLevel(logging.ERROR)
442442 logger.addHandler(logging.StreamHandler())
443443
444+ On Python 3.5, :func:`serve` can be used as a asynchronous context
445+ manager. In that case, the server is shut down when exiting the context.
446+
444447 """
445448 if loop is None :
446449 loop = asyncio .get_event_loop ()
@@ -462,3 +465,14 @@ def serve(ws_handler, host=None, port=None, *,
462465 ws_server .wrap (server )
463466
464467 return ws_server
468+
469+
470+ try :
471+ from .py35 .server import Serve
472+ except (SyntaxError , ImportError ): # pragma: no cover
473+ pass
474+ else :
475+ Serve .__wrapped__ = serve
476+ # Copy over docstring to support building documentation on Python 3.5.
477+ Serve .__doc__ = serve .__doc__
478+ serve = Serve
0 commit comments