mirror of https://github.com/python/cpython
(Merge 3.4) Tulip issue 83: document more asyncio functions in docstrings
This commit is contained in:
commit
037fa45a9f
|
@ -311,11 +311,10 @@ 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)
|
||||
|
||||
A :ref:`coroutine <coroutine>` method which creates a TCP server bound to
|
||||
host and port.
|
||||
Create a TCP server bound to host and port. Return an
|
||||
:class:`AbstractServer` object which can be used to stop the service.
|
||||
|
||||
The return value is a :class:`AbstractServer` object which can be used to stop
|
||||
the service.
|
||||
This method is a :ref:`coroutine <coroutine>`.
|
||||
|
||||
If *host* is an empty string or None all interfaces are assumed
|
||||
and a list of multiple sockets will be returned (most likely
|
||||
|
|
|
@ -320,7 +320,7 @@ class BaseEventLoop(events.AbstractEventLoop):
|
|||
"than the current one")
|
||||
|
||||
def call_soon_threadsafe(self, callback, *args):
|
||||
"""XXX"""
|
||||
"""Like call_soon(), but thread safe."""
|
||||
handle = self._call_soon(callback, args, check_loop=False)
|
||||
self._write_to_self()
|
||||
return handle
|
||||
|
@ -358,7 +358,17 @@ class BaseEventLoop(events.AbstractEventLoop):
|
|||
def create_connection(self, protocol_factory, host=None, port=None, *,
|
||||
ssl=None, family=0, proto=0, flags=0, sock=None,
|
||||
local_addr=None, server_hostname=None):
|
||||
"""XXX"""
|
||||
"""Connect to a TCP server.
|
||||
|
||||
Create a streaming transport connection to a given Internet host and
|
||||
port: socket family AF_INET or socket.AF_INET6 depending on host (or
|
||||
family if specified), socket type SOCK_STREAM. protocol_factory must be
|
||||
a callable returning a protocol instance.
|
||||
|
||||
This method is a coroutine which will try to establish the connection
|
||||
in the background. When successful, the coroutine returns a
|
||||
(transport, protocol) pair.
|
||||
"""
|
||||
if server_hostname is not None and not ssl:
|
||||
raise ValueError('server_hostname is only meaningful with ssl')
|
||||
|
||||
|
@ -557,7 +567,12 @@ class BaseEventLoop(events.AbstractEventLoop):
|
|||
backlog=100,
|
||||
ssl=None,
|
||||
reuse_address=None):
|
||||
"""XXX"""
|
||||
"""Create a TCP server bound to host and port.
|
||||
|
||||
Return an AbstractServer object which can be used to stop the service.
|
||||
|
||||
This method is a coroutine.
|
||||
"""
|
||||
if isinstance(ssl, bool):
|
||||
raise TypeError('ssl argument must be an SSLContext or None')
|
||||
if host is not None or port is not None:
|
||||
|
|
|
@ -226,7 +226,14 @@ class BaseSelectorEventLoop(base_events.BaseEventLoop):
|
|||
return False
|
||||
|
||||
def sock_recv(self, sock, n):
|
||||
"""XXX"""
|
||||
"""Receive data from the socket.
|
||||
|
||||
The return value is a bytes object representing the data received.
|
||||
The maximum amount of data to be received at once is specified by
|
||||
nbytes.
|
||||
|
||||
This method is a coroutine.
|
||||
"""
|
||||
fut = futures.Future(loop=self)
|
||||
self._sock_recv(fut, False, sock, n)
|
||||
return fut
|
||||
|
@ -253,7 +260,16 @@ class BaseSelectorEventLoop(base_events.BaseEventLoop):
|
|||
fut.set_result(data)
|
||||
|
||||
def sock_sendall(self, sock, data):
|
||||
"""XXX"""
|
||||
"""Send data to the socket.
|
||||
|
||||
The socket must be connected to a remote socket. This method continues
|
||||
to send data from data until either all data has been sent or an
|
||||
error occurs. None is returned on success. On error, an exception is
|
||||
raised, and there is no way to determine how much data, if any, was
|
||||
successfully processed by the receiving end of the connection.
|
||||
|
||||
This method is a coroutine.
|
||||
"""
|
||||
fut = futures.Future(loop=self)
|
||||
if data:
|
||||
self._sock_sendall(fut, False, sock, data)
|
||||
|
@ -285,7 +301,16 @@ class BaseSelectorEventLoop(base_events.BaseEventLoop):
|
|||
self.add_writer(fd, self._sock_sendall, fut, True, sock, data)
|
||||
|
||||
def sock_connect(self, sock, address):
|
||||
"""XXX"""
|
||||
"""Connect to a remote socket at address.
|
||||
|
||||
The address must be already resolved to avoid the trap of hanging the
|
||||
entire event loop when the address requires doing a DNS lookup. For
|
||||
example, it must be an IP address, not an hostname, for AF_INET and
|
||||
AF_INET6 address families. Use getaddrinfo() to resolve the hostname
|
||||
asynchronously.
|
||||
|
||||
This method is a coroutine.
|
||||
"""
|
||||
fut = futures.Future(loop=self)
|
||||
try:
|
||||
base_events._check_resolved_address(sock, address)
|
||||
|
@ -318,7 +343,15 @@ class BaseSelectorEventLoop(base_events.BaseEventLoop):
|
|||
fut.set_result(None)
|
||||
|
||||
def sock_accept(self, sock):
|
||||
"""XXX"""
|
||||
"""Accept a connection.
|
||||
|
||||
The socket must be bound to an address and listening for connections.
|
||||
The return value is a pair (conn, address) where conn is a new socket
|
||||
object usable to send and receive data on the connection, and address
|
||||
is the address bound to the socket on the other end of the connection.
|
||||
|
||||
This method is a coroutine.
|
||||
"""
|
||||
fut = futures.Future(loop=self)
|
||||
self._sock_accept(fut, False, sock)
|
||||
return fut
|
||||
|
|
Loading…
Reference in New Issue