diff --git a/Doc/library/asyncio-eventloop.rst b/Doc/library/asyncio-eventloop.rst --- a/Doc/library/asyncio-eventloop.rst +++ b/Doc/library/asyncio-eventloop.rst @@ -533,45 +533,45 @@ On Windows with :class:`ProactorEventLoo The :ref:`watch a file descriptor for read events ` example uses the low-level :meth:`AbstractEventLoop.add_reader` method to register the file descriptor of a socket. Low-level socket operations --------------------------- -.. coroutinemethod:: AbstractEventLoop.sock_recv(sock, nbytes) +.. method:: AbstractEventLoop.sock_recv(sock, nbytes) Receive data from the socket. Modeled after blocking :meth:`socket.socket.recv` method. 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*. With :class:`SelectorEventLoop` event loop, the socket *sock* must be non-blocking. - This method is a :ref:`coroutine `. + This method returns a :class:`~asyncio.Future` object. -.. coroutinemethod:: AbstractEventLoop.sock_sendall(sock, data) +.. method:: AbstractEventLoop.sock_sendall(sock, data) Send data to the socket. Modeled after blocking :meth:`socket.socket.sendall` method. 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. With :class:`SelectorEventLoop` event loop, the socket *sock* must be non-blocking. - This method is a :ref:`coroutine `. + This method returns a :class:`~asyncio.Future` object. .. coroutinemethod:: AbstractEventLoop.sock_connect(sock, address) Connect to a remote socket at *address*. Modeled after blocking :meth:`socket.socket.connect` method. With :class:`SelectorEventLoop` event loop, the socket *sock* must be non-blocking. @@ -586,30 +586,30 @@ Low-level socket operations *address*. .. seealso:: :meth:`AbstractEventLoop.create_connection` and :func:`asyncio.open_connection() `. -.. coroutinemethod:: AbstractEventLoop.sock_accept(sock) +.. method:: AbstractEventLoop.sock_accept(sock) Accept a connection. Modeled after blocking :meth:`socket.socket.accept`. 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. The socket *sock* must be non-blocking. - This method is a :ref:`coroutine `. + This method returns a :class:`~asyncio.Future` object. .. seealso:: :meth:`AbstractEventLoop.create_server` and :func:`start_server`. Resolve host name ----------------- diff --git a/Lib/asyncio/selector_events.py b/Lib/asyncio/selector_events.py --- a/Lib/asyncio/selector_events.py +++ b/Lib/asyncio/selector_events.py @@ -353,17 +353,17 @@ class BaseSelectorEventLoop(base_events. def sock_recv(self, sock, n): """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. + This method returns a Future object. """ if self._debug and sock.gettimeout() != 0: raise ValueError("the socket must be non-blocking") fut = self.create_future() self._sock_recv(fut, False, sock, n) return fut def _sock_recv(self, fut, registered, sock, n): @@ -391,17 +391,17 @@ class BaseSelectorEventLoop(base_events. """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. + This method returns a Future object. """ if self._debug and sock.gettimeout() != 0: raise ValueError("the socket must be non-blocking") fut = self.create_future() if data: self._sock_sendall(fut, False, sock, data) else: fut.set_result(None) @@ -490,17 +490,17 @@ class BaseSelectorEventLoop(base_events. def sock_accept(self, sock): """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. + This method returns a Future object. """ if self._debug and sock.gettimeout() != 0: raise ValueError("the socket must be non-blocking") fut = self.create_future() self._sock_accept(fut, False, sock) return fut def _sock_accept(self, fut, registered, sock):