Skip to content

Commit 5ec4bf8

Browse files
sobolevnAA-Turner
andauthored
gh-121970: Replace .. coroutine{method,function} with :async: (#130448)
Co-authored-by: Adam Turner <[email protected]>
1 parent 3cc9e86 commit 5ec4bf8

10 files changed

+197
-150
lines changed

Doc/library/asyncio-eventloop.rst

+95-67
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,8 @@ Running and stopping the loop
172172
This method is idempotent and irreversible. No other methods
173173
should be called after the event loop is closed.
174174

175-
.. coroutinemethod:: loop.shutdown_asyncgens()
175+
.. method:: loop.shutdown_asyncgens()
176+
:async:
176177

177178
Schedule all currently open :term:`asynchronous generator` objects to
178179
close with an :meth:`~agen.aclose` call. After calling this method,
@@ -193,7 +194,8 @@ Running and stopping the loop
193194

194195
.. versionadded:: 3.6
195196

196-
.. coroutinemethod:: loop.shutdown_default_executor(timeout=None)
197+
.. method:: loop.shutdown_default_executor(timeout=None)
198+
:async:
197199

198200
Schedule the closure of the default executor and wait for it to join all of
199201
the threads in the :class:`~concurrent.futures.ThreadPoolExecutor`.
@@ -404,14 +406,15 @@ Creating Futures and Tasks
404406
Opening network connections
405407
^^^^^^^^^^^^^^^^^^^^^^^^^^^
406408

407-
.. coroutinemethod:: loop.create_connection(protocol_factory, \
408-
host=None, port=None, *, ssl=None, \
409-
family=0, proto=0, flags=0, sock=None, \
410-
local_addr=None, server_hostname=None, \
411-
ssl_handshake_timeout=None, \
412-
ssl_shutdown_timeout=None, \
413-
happy_eyeballs_delay=None, interleave=None, \
414-
all_errors=False)
409+
.. method:: loop.create_connection(protocol_factory, \
410+
host=None, port=None, *, ssl=None, \
411+
family=0, proto=0, flags=0, sock=None, \
412+
local_addr=None, server_hostname=None, \
413+
ssl_handshake_timeout=None, \
414+
ssl_shutdown_timeout=None, \
415+
happy_eyeballs_delay=None, interleave=None, \
416+
all_errors=False)
417+
:async:
415418
416419
Open a streaming transport connection to a given
417420
address specified by *host* and *port*.
@@ -557,11 +560,12 @@ Opening network connections
557560
API. It returns a pair of (:class:`StreamReader`, :class:`StreamWriter`)
558561
that can be used directly in async/await code.
559562

560-
.. coroutinemethod:: loop.create_datagram_endpoint(protocol_factory, \
561-
local_addr=None, remote_addr=None, *, \
562-
family=0, proto=0, flags=0, \
563-
reuse_port=None, \
564-
allow_broadcast=None, sock=None)
563+
.. method:: loop.create_datagram_endpoint(protocol_factory, \
564+
local_addr=None, remote_addr=None, *, \
565+
family=0, proto=0, flags=0, \
566+
reuse_port=None, \
567+
allow_broadcast=None, sock=None)
568+
:async:
565569
566570
Create a datagram connection.
567571

@@ -642,10 +646,11 @@ Opening network connections
642646
The *reuse_address* parameter, disabled since Python 3.8.1,
643647
3.7.6 and 3.6.10, has been entirely removed.
644648

645-
.. coroutinemethod:: loop.create_unix_connection(protocol_factory, \
646-
path=None, *, ssl=None, sock=None, \
647-
server_hostname=None, ssl_handshake_timeout=None, \
648-
ssl_shutdown_timeout=None)
649+
.. method:: loop.create_unix_connection(protocol_factory, \
650+
path=None, *, ssl=None, sock=None, \
651+
server_hostname=None, ssl_handshake_timeout=None, \
652+
ssl_shutdown_timeout=None)
653+
:async:
649654
650655
Create a Unix connection.
651656

@@ -678,16 +683,17 @@ Creating network servers
678683

679684
.. _loop_create_server:
680685

681-
.. coroutinemethod:: loop.create_server(protocol_factory, \
682-
host=None, port=None, *, \
683-
family=socket.AF_UNSPEC, \
684-
flags=socket.AI_PASSIVE, \
685-
sock=None, backlog=100, ssl=None, \
686-
reuse_address=None, reuse_port=None, \
687-
keep_alive=None, \
688-
ssl_handshake_timeout=None, \
689-
ssl_shutdown_timeout=None, \
690-
start_serving=True)
686+
.. method:: loop.create_server(protocol_factory, \
687+
host=None, port=None, *, \
688+
family=socket.AF_UNSPEC, \
689+
flags=socket.AI_PASSIVE, \
690+
sock=None, backlog=100, ssl=None, \
691+
reuse_address=None, reuse_port=None, \
692+
keep_alive=None, \
693+
ssl_handshake_timeout=None, \
694+
ssl_shutdown_timeout=None, \
695+
start_serving=True)
696+
:async:
691697
692698
Create a TCP server (socket type :const:`~socket.SOCK_STREAM`) listening
693699
on *port* of the *host* address.
@@ -795,11 +801,12 @@ Creating network servers
795801
that can be used in an async/await code.
796802

797803

798-
.. coroutinemethod:: loop.create_unix_server(protocol_factory, path=None, \
799-
*, sock=None, backlog=100, ssl=None, \
800-
ssl_handshake_timeout=None, \
801-
ssl_shutdown_timeout=None, \
802-
start_serving=True, cleanup_socket=True)
804+
.. method:: loop.create_unix_server(protocol_factory, path=None, \
805+
*, sock=None, backlog=100, ssl=None, \
806+
ssl_handshake_timeout=None, \
807+
ssl_shutdown_timeout=None, \
808+
start_serving=True, cleanup_socket=True)
809+
:async:
803810
804811
Similar to :meth:`loop.create_server` but works with the
805812
:py:const:`~socket.AF_UNIX` socket family.
@@ -832,9 +839,10 @@ Creating network servers
832839
Added the *cleanup_socket* parameter.
833840

834841

835-
.. coroutinemethod:: loop.connect_accepted_socket(protocol_factory, \
836-
sock, *, ssl=None, ssl_handshake_timeout=None, \
837-
ssl_shutdown_timeout=None)
842+
.. method:: loop.connect_accepted_socket(protocol_factory, \
843+
sock, *, ssl=None, ssl_handshake_timeout=None, \
844+
ssl_shutdown_timeout=None)
845+
:async:
838846
839847
Wrap an already accepted connection into a transport/protocol pair.
840848

@@ -882,8 +890,9 @@ Creating network servers
882890
Transferring files
883891
^^^^^^^^^^^^^^^^^^
884892

885-
.. coroutinemethod:: loop.sendfile(transport, file, \
886-
offset=0, count=None, *, fallback=True)
893+
.. method:: loop.sendfile(transport, file, \
894+
offset=0, count=None, *, fallback=True)
895+
:async:
887896
888897
Send a *file* over a *transport*. Return the total number of bytes
889898
sent.
@@ -912,10 +921,11 @@ Transferring files
912921
TLS Upgrade
913922
^^^^^^^^^^^
914923

915-
.. coroutinemethod:: loop.start_tls(transport, protocol, \
916-
sslcontext, *, server_side=False, \
917-
server_hostname=None, ssl_handshake_timeout=None, \
918-
ssl_shutdown_timeout=None)
924+
.. method:: loop.start_tls(transport, protocol, \
925+
sslcontext, *, server_side=False, \
926+
server_hostname=None, ssl_handshake_timeout=None, \
927+
ssl_shutdown_timeout=None)
928+
:async:
919929
920930
Upgrade an existing transport-based connection to TLS.
921931

@@ -1009,7 +1019,8 @@ However, there are some use cases when performance is not critical, and
10091019
working with :class:`~socket.socket` objects directly is more
10101020
convenient.
10111021

1012-
.. coroutinemethod:: loop.sock_recv(sock, nbytes)
1022+
.. method:: loop.sock_recv(sock, nbytes)
1023+
:async:
10131024

10141025
Receive up to *nbytes* from *sock*. Asynchronous version of
10151026
:meth:`socket.recv() <socket.socket.recv>`.
@@ -1023,7 +1034,8 @@ convenient.
10231034
method, releases before Python 3.7 returned a :class:`Future`.
10241035
Since Python 3.7 this is an ``async def`` method.
10251036

1026-
.. coroutinemethod:: loop.sock_recv_into(sock, buf)
1037+
.. method:: loop.sock_recv_into(sock, buf)
1038+
:async:
10271039

10281040
Receive data from *sock* into the *buf* buffer. Modeled after the blocking
10291041
:meth:`socket.recv_into() <socket.socket.recv_into>` method.
@@ -1034,7 +1046,8 @@ convenient.
10341046

10351047
.. versionadded:: 3.7
10361048

1037-
.. coroutinemethod:: loop.sock_recvfrom(sock, bufsize)
1049+
.. method:: loop.sock_recvfrom(sock, bufsize)
1050+
:async:
10381051

10391052
Receive a datagram of up to *bufsize* from *sock*. Asynchronous version of
10401053
:meth:`socket.recvfrom() <socket.socket.recvfrom>`.
@@ -1045,7 +1058,8 @@ convenient.
10451058

10461059
.. versionadded:: 3.11
10471060

1048-
.. coroutinemethod:: loop.sock_recvfrom_into(sock, buf, nbytes=0)
1061+
.. method:: loop.sock_recvfrom_into(sock, buf, nbytes=0)
1062+
:async:
10491063

10501064
Receive a datagram of up to *nbytes* from *sock* into *buf*.
10511065
Asynchronous version of
@@ -1057,7 +1071,8 @@ convenient.
10571071

10581072
.. versionadded:: 3.11
10591073

1060-
.. coroutinemethod:: loop.sock_sendall(sock, data)
1074+
.. method:: loop.sock_sendall(sock, data)
1075+
:async:
10611076

10621077
Send *data* to the *sock* socket. Asynchronous version of
10631078
:meth:`socket.sendall() <socket.socket.sendall>`.
@@ -1075,7 +1090,8 @@ convenient.
10751090
method, before Python 3.7 it returned a :class:`Future`.
10761091
Since Python 3.7, this is an ``async def`` method.
10771092

1078-
.. coroutinemethod:: loop.sock_sendto(sock, data, address)
1093+
.. method:: loop.sock_sendto(sock, data, address)
1094+
:async:
10791095

10801096
Send a datagram from *sock* to *address*.
10811097
Asynchronous version of
@@ -1087,7 +1103,8 @@ convenient.
10871103

10881104
.. versionadded:: 3.11
10891105

1090-
.. coroutinemethod:: loop.sock_connect(sock, address)
1106+
.. method:: loop.sock_connect(sock, address)
1107+
:async:
10911108

10921109
Connect *sock* to a remote socket at *address*.
10931110

@@ -1108,7 +1125,8 @@ convenient.
11081125
and :func:`asyncio.open_connection() <open_connection>`.
11091126

11101127

1111-
.. coroutinemethod:: loop.sock_accept(sock)
1128+
.. method:: loop.sock_accept(sock)
1129+
:async:
11121130

11131131
Accept a connection. Modeled after the blocking
11141132
:meth:`socket.accept() <socket.socket.accept>` method.
@@ -1130,8 +1148,9 @@ convenient.
11301148

11311149
:meth:`loop.create_server` and :func:`start_server`.
11321150

1133-
.. coroutinemethod:: loop.sock_sendfile(sock, file, offset=0, count=None, \
1134-
*, fallback=True)
1151+
.. method:: loop.sock_sendfile(sock, file, offset=0, count=None, \
1152+
*, fallback=True)
1153+
:async:
11351154
11361155
Send a file using high-performance :mod:`os.sendfile` if possible.
11371156
Return the total number of bytes sent.
@@ -1165,12 +1184,14 @@ convenient.
11651184
DNS
11661185
^^^
11671186

1168-
.. coroutinemethod:: loop.getaddrinfo(host, port, *, family=0, \
1169-
type=0, proto=0, flags=0)
1187+
.. method:: loop.getaddrinfo(host, port, *, family=0, \
1188+
type=0, proto=0, flags=0)
1189+
:async:
11701190

11711191
Asynchronous version of :meth:`socket.getaddrinfo`.
11721192

1173-
.. coroutinemethod:: loop.getnameinfo(sockaddr, flags=0)
1193+
.. method:: loop.getnameinfo(sockaddr, flags=0)
1194+
:async:
11741195

11751196
Asynchronous version of :meth:`socket.getnameinfo`.
11761197

@@ -1192,7 +1213,8 @@ DNS
11921213
Working with pipes
11931214
^^^^^^^^^^^^^^^^^^
11941215

1195-
.. coroutinemethod:: loop.connect_read_pipe(protocol_factory, pipe)
1216+
.. method:: loop.connect_read_pipe(protocol_factory, pipe)
1217+
:async:
11961218

11971219
Register the read end of *pipe* in the event loop.
11981220

@@ -1208,7 +1230,8 @@ Working with pipes
12081230
With :class:`SelectorEventLoop` event loop, the *pipe* is set to
12091231
non-blocking mode.
12101232

1211-
.. coroutinemethod:: loop.connect_write_pipe(protocol_factory, pipe)
1233+
.. method:: loop.connect_write_pipe(protocol_factory, pipe)
1234+
:async:
12121235

12131236
Register the write end of *pipe* in the event loop.
12141237

@@ -1480,9 +1503,10 @@ async/await code consider using the high-level
14801503

14811504
.. _loop_subprocess_exec:
14821505

1483-
.. coroutinemethod:: loop.subprocess_exec(protocol_factory, *args, \
1484-
stdin=subprocess.PIPE, stdout=subprocess.PIPE, \
1485-
stderr=subprocess.PIPE, **kwargs)
1506+
.. method:: loop.subprocess_exec(protocol_factory, *args, \
1507+
stdin=subprocess.PIPE, stdout=subprocess.PIPE, \
1508+
stderr=subprocess.PIPE, **kwargs)
1509+
:async:
14861510
14871511
Create a subprocess from one or more string arguments specified by
14881512
*args*.
@@ -1562,9 +1586,10 @@ async/await code consider using the high-level
15621586
conforms to the :class:`asyncio.SubprocessTransport` base class and
15631587
*protocol* is an object instantiated by the *protocol_factory*.
15641588

1565-
.. coroutinemethod:: loop.subprocess_shell(protocol_factory, cmd, *, \
1566-
stdin=subprocess.PIPE, stdout=subprocess.PIPE, \
1567-
stderr=subprocess.PIPE, **kwargs)
1589+
.. method:: loop.subprocess_shell(protocol_factory, cmd, *, \
1590+
stdin=subprocess.PIPE, stdout=subprocess.PIPE, \
1591+
stderr=subprocess.PIPE, **kwargs)
1592+
:async:
15681593
15691594
Create a subprocess from *cmd*, which can be a :class:`str` or a
15701595
:class:`bytes` string encoded to the
@@ -1709,7 +1734,8 @@ Do not instantiate the :class:`Server` class directly.
17091734

17101735
.. versionadded:: 3.7
17111736

1712-
.. coroutinemethod:: start_serving()
1737+
.. method:: start_serving()
1738+
:async:
17131739

17141740
Start accepting connections.
17151741

@@ -1725,7 +1751,8 @@ Do not instantiate the :class:`Server` class directly.
17251751

17261752
.. versionadded:: 3.7
17271753

1728-
.. coroutinemethod:: serve_forever()
1754+
.. method:: serve_forever()
1755+
:async:
17291756

17301757
Start accepting connections until the coroutine is cancelled.
17311758
Cancellation of ``serve_forever`` task causes the server
@@ -1757,7 +1784,8 @@ Do not instantiate the :class:`Server` class directly.
17571784

17581785
.. versionadded:: 3.7
17591786

1760-
.. coroutinemethod:: wait_closed()
1787+
.. method:: wait_closed()
1788+
:async:
17611789

17621790
Wait until the :meth:`close` method completes and all active
17631791
connections have finished.

Doc/library/asyncio-queue.rst

+6-3
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ Queue
5757
If the queue was initialized with ``maxsize=0`` (the default),
5858
then :meth:`full` never returns ``True``.
5959

60-
.. coroutinemethod:: get()
60+
.. method:: get()
61+
:async:
6162

6263
Remove and return an item from the queue. If queue is empty,
6364
wait until an item is available.
@@ -70,7 +71,8 @@ Queue
7071
Return an item if one is immediately available, else raise
7172
:exc:`QueueEmpty`.
7273

73-
.. coroutinemethod:: join()
74+
.. method:: join()
75+
:async:
7476

7577
Block until all items in the queue have been received and processed.
7678

@@ -80,7 +82,8 @@ Queue
8082
work on it is complete. When the count of unfinished tasks drops
8183
to zero, :meth:`join` unblocks.
8284

83-
.. coroutinemethod:: put(item)
85+
.. method:: put(item)
86+
:async:
8487

8588
Put an item into the queue. If the queue is full, wait until a
8689
free slot is available before adding the item.

0 commit comments

Comments
 (0)