diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2014-07-11 21:47:40 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2014-07-11 21:47:40 (GMT) |
commit | 8ebeb03740dad4d9edd65de88f82840a05070941 (patch) | |
tree | 6c77cc790d68d27fc85d41ed41991271db2d4ea1 /Doc/library/asyncio-eventloop.rst | |
parent | b28dbac86d3c8ccde7d16c4f2de471eb53a6bffe (diff) | |
download | cpython-8ebeb03740dad4d9edd65de88f82840a05070941.zip cpython-8ebeb03740dad4d9edd65de88f82840a05070941.tar.gz cpython-8ebeb03740dad4d9edd65de88f82840a05070941.tar.bz2 |
asyncio: improve the documentation of servers
- Fix the documentation of Server.close(): it closes sockets
- Replace AbstractServer with Server
- Document Server.sockets attribute
Diffstat (limited to 'Doc/library/asyncio-eventloop.rst')
-rw-r--r-- | Doc/library/asyncio-eventloop.rst | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/Doc/library/asyncio-eventloop.rst b/Doc/library/asyncio-eventloop.rst index c82ea48..993a5de 100644 --- a/Doc/library/asyncio-eventloop.rst +++ b/Doc/library/asyncio-eventloop.rst @@ -263,8 +263,9 @@ Creating listening connections .. method:: BaseEventLoop.create_server(protocol_factory, host=None, port=None, \*, family=socket.AF_UNSPEC, flags=socket.AI_PASSIVE, sock=None, backlog=100, ssl=None, reuse_address=None) - Create a TCP server bound to host and port. Return an - :class:`AbstractServer` object which can be used to stop the service. + Create a TCP server bound to host and port. Return a :class:`Server` object, + its :attr:`~Server.sockets` attribute contains created sockets. Use the + :meth:`Server.close` method to stop the server: close listening sockets. This method is a :ref:`coroutine <coroutine>`. @@ -557,17 +558,31 @@ Debug mode Server ------ -.. class:: AbstractServer +.. class:: Server - Abstract server returned by :func:`BaseEventLoop.create_server`. + Server listening on sockets. + + Object created by the :meth:`BaseEventLoop.create_server` method and the + :func:`start_server` function. Don't instanciate the class directly. .. method:: close() - Stop serving. This leaves existing connections open. + Stop serving: close all sockets and set the :attr:`sockets` attribute to + ``None``. + + The server is closed asynchonously, use the :meth:`wait_closed` coroutine + to wait until the server is closed. .. method:: wait_closed() - A :ref:`coroutine <coroutine>` to wait until service is closed. + Wait until the :meth:`close` method completes. + + This method is a :ref:`coroutine <coroutine>`. + + .. attribute:: sockets + + List of :class:`socket.socket` objects the server is listening to, or + ``None`` if the server is closed. Handle |