Skip to content

Commit c68a872

Browse files
miss-islingtonsobolevnAA-Turner
authored
[3.13] gh-121970: Replace .. coroutine{method,function} with :async: (GH-130448) (#130465)
(cherry picked from commit 5ec4bf8) Co-authored-by: sobolevn <mail@sobolevn.me> Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
1 parent 2412c91 commit c68a872

10 files changed

+197
-150
lines changed

Doc/library/asyncio-eventloop.rst

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

165-
.. coroutinemethod:: loop.shutdown_asyncgens()
165+
.. method:: loop.shutdown_asyncgens()
166+
:async:
166167

167168
Schedule all currently open :term:`asynchronous generator` objects to
168169
close with an :meth:`~agen.aclose` call. After calling this method,
@@ -183,7 +184,8 @@ Running and stopping the loop
183184

184185
.. versionadded:: 3.6
185186

186-
.. coroutinemethod:: loop.shutdown_default_executor(timeout=None)
187+
.. method:: loop.shutdown_default_executor(timeout=None)
188+
:async:
187189

188190
Schedule the closure of the default executor and wait for it to join all of
189191
the threads in the :class:`~concurrent.futures.ThreadPoolExecutor`.
@@ -394,14 +396,15 @@ Creating Futures and Tasks
394396
Opening network connections
395397
^^^^^^^^^^^^^^^^^^^^^^^^^^^
396398

397-
.. coroutinemethod:: loop.create_connection(protocol_factory, \
398-
host=None, port=None, *, ssl=None, \
399-
family=0, proto=0, flags=0, sock=None, \
400-
local_addr=None, server_hostname=None, \
401-
ssl_handshake_timeout=None, \
402-
ssl_shutdown_timeout=None, \
403-
happy_eyeballs_delay=None, interleave=None, \
404-
all_errors=False)
399+
.. method:: loop.create_connection(protocol_factory, \
400+
host=None, port=None, *, ssl=None, \
401+
family=0, proto=0, flags=0, sock=None, \
402+
local_addr=None, server_hostname=None, \
403+
ssl_handshake_timeout=None, \
404+
ssl_shutdown_timeout=None, \
405+
happy_eyeballs_delay=None, interleave=None, \
406+
all_errors=False)
407+
:async:
405408
406409
Open a streaming transport connection to a given
407410
address specified by *host* and *port*.
@@ -547,11 +550,12 @@ Opening network connections
547550
API. It returns a pair of (:class:`StreamReader`, :class:`StreamWriter`)
548551
that can be used directly in async/await code.
549552

550-
.. coroutinemethod:: loop.create_datagram_endpoint(protocol_factory, \
551-
local_addr=None, remote_addr=None, *, \
552-
family=0, proto=0, flags=0, \
553-
reuse_port=None, \
554-
allow_broadcast=None, sock=None)
553+
.. method:: loop.create_datagram_endpoint(protocol_factory, \
554+
local_addr=None, remote_addr=None, *, \
555+
family=0, proto=0, flags=0, \
556+
reuse_port=None, \
557+
allow_broadcast=None, sock=None)
558+
:async:
555559
556560
Create a datagram connection.
557561

@@ -632,10 +636,11 @@ Opening network connections
632636
The *reuse_address* parameter, disabled since Python 3.8.1,
633637
3.7.6 and 3.6.10, has been entirely removed.
634638

635-
.. coroutinemethod:: loop.create_unix_connection(protocol_factory, \
636-
path=None, *, ssl=None, sock=None, \
637-
server_hostname=None, ssl_handshake_timeout=None, \
638-
ssl_shutdown_timeout=None)
639+
.. method:: loop.create_unix_connection(protocol_factory, \
640+
path=None, *, ssl=None, sock=None, \
641+
server_hostname=None, ssl_handshake_timeout=None, \
642+
ssl_shutdown_timeout=None)
643+
:async:
639644
640645
Create a Unix connection.
641646

@@ -668,16 +673,17 @@ Creating network servers
668673

669674
.. _loop_create_server:
670675

671-
.. coroutinemethod:: loop.create_server(protocol_factory, \
672-
host=None, port=None, *, \
673-
family=socket.AF_UNSPEC, \
674-
flags=socket.AI_PASSIVE, \
675-
sock=None, backlog=100, ssl=None, \
676-
reuse_address=None, reuse_port=None, \
677-
keep_alive=None, \
678-
ssl_handshake_timeout=None, \
679-
ssl_shutdown_timeout=None, \
680-
start_serving=True)
676+
.. method:: loop.create_server(protocol_factory, \
677+
host=None, port=None, *, \
678+
family=socket.AF_UNSPEC, \
679+
flags=socket.AI_PASSIVE, \
680+
sock=None, backlog=100, ssl=None, \
681+
reuse_address=None, reuse_port=None, \
682+
keep_alive=None, \
683+
ssl_handshake_timeout=None, \
684+
ssl_shutdown_timeout=None, \
685+
start_serving=True)
686+
:async:
681687
682688
Create a TCP server (socket type :const:`~socket.SOCK_STREAM`) listening
683689
on *port* of the *host* address.
@@ -785,11 +791,12 @@ Creating network servers
785791
that can be used in an async/await code.
786792

787793

788-
.. coroutinemethod:: loop.create_unix_server(protocol_factory, path=None, \
789-
*, sock=None, backlog=100, ssl=None, \
790-
ssl_handshake_timeout=None, \
791-
ssl_shutdown_timeout=None, \
792-
start_serving=True, cleanup_socket=True)
794+
.. method:: loop.create_unix_server(protocol_factory, path=None, \
795+
*, sock=None, backlog=100, ssl=None, \
796+
ssl_handshake_timeout=None, \
797+
ssl_shutdown_timeout=None, \
798+
start_serving=True, cleanup_socket=True)
799+
:async:
793800
794801
Similar to :meth:`loop.create_server` but works with the
795802
:py:const:`~socket.AF_UNIX` socket family.
@@ -822,9 +829,10 @@ Creating network servers
822829
Added the *cleanup_socket* parameter.
823830

824831

825-
.. coroutinemethod:: loop.connect_accepted_socket(protocol_factory, \
826-
sock, *, ssl=None, ssl_handshake_timeout=None, \
827-
ssl_shutdown_timeout=None)
832+
.. method:: loop.connect_accepted_socket(protocol_factory, \
833+
sock, *, ssl=None, ssl_handshake_timeout=None, \
834+
ssl_shutdown_timeout=None)
835+
:async:
828836
829837
Wrap an already accepted connection into a transport/protocol pair.
830838

@@ -872,8 +880,9 @@ Creating network servers
872880
Transferring files
873881
^^^^^^^^^^^^^^^^^^
874882

875-
.. coroutinemethod:: loop.sendfile(transport, file, \
876-
offset=0, count=None, *, fallback=True)
883+
.. method:: loop.sendfile(transport, file, \
884+
offset=0, count=None, *, fallback=True)
885+
:async:
877886
878887
Send a *file* over a *transport*. Return the total number of bytes
879888
sent.
@@ -902,10 +911,11 @@ Transferring files
902911
TLS Upgrade
903912
^^^^^^^^^^^
904913

905-
.. coroutinemethod:: loop.start_tls(transport, protocol, \
906-
sslcontext, *, server_side=False, \
907-
server_hostname=None, ssl_handshake_timeout=None, \
908-
ssl_shutdown_timeout=None)
914+
.. method:: loop.start_tls(transport, protocol, \
915+
sslcontext, *, server_side=False, \
916+
server_hostname=None, ssl_handshake_timeout=None, \
917+
ssl_shutdown_timeout=None)
918+
:async:
909919
910920
Upgrade an existing transport-based connection to TLS.
911921

@@ -999,7 +1009,8 @@ However, there are some use cases when performance is not critical, and
9991009
working with :class:`~socket.socket` objects directly is more
10001010
convenient.
10011011

1002-
.. coroutinemethod:: loop.sock_recv(sock, nbytes)
1012+
.. method:: loop.sock_recv(sock, nbytes)
1013+
:async:
10031014

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

1016-
.. coroutinemethod:: loop.sock_recv_into(sock, buf)
1027+
.. method:: loop.sock_recv_into(sock, buf)
1028+
:async:
10171029

10181030
Receive data from *sock* into the *buf* buffer. Modeled after the blocking
10191031
:meth:`socket.recv_into() <socket.socket.recv_into>` method.
@@ -1024,7 +1036,8 @@ convenient.
10241036

10251037
.. versionadded:: 3.7
10261038

1027-
.. coroutinemethod:: loop.sock_recvfrom(sock, bufsize)
1039+
.. method:: loop.sock_recvfrom(sock, bufsize)
1040+
:async:
10281041

10291042
Receive a datagram of up to *bufsize* from *sock*. Asynchronous version of
10301043
:meth:`socket.recvfrom() <socket.socket.recvfrom>`.
@@ -1035,7 +1048,8 @@ convenient.
10351048

10361049
.. versionadded:: 3.11
10371050

1038-
.. coroutinemethod:: loop.sock_recvfrom_into(sock, buf, nbytes=0)
1051+
.. method:: loop.sock_recvfrom_into(sock, buf, nbytes=0)
1052+
:async:
10391053

10401054
Receive a datagram of up to *nbytes* from *sock* into *buf*.
10411055
Asynchronous version of
@@ -1047,7 +1061,8 @@ convenient.
10471061

10481062
.. versionadded:: 3.11
10491063

1050-
.. coroutinemethod:: loop.sock_sendall(sock, data)
1064+
.. method:: loop.sock_sendall(sock, data)
1065+
:async:
10511066

10521067
Send *data* to the *sock* socket. Asynchronous version of
10531068
:meth:`socket.sendall() <socket.socket.sendall>`.
@@ -1065,7 +1080,8 @@ convenient.
10651080
method, before Python 3.7 it returned a :class:`Future`.
10661081
Since Python 3.7, this is an ``async def`` method.
10671082

1068-
.. coroutinemethod:: loop.sock_sendto(sock, data, address)
1083+
.. method:: loop.sock_sendto(sock, data, address)
1084+
:async:
10691085

10701086
Send a datagram from *sock* to *address*.
10711087
Asynchronous version of
@@ -1077,7 +1093,8 @@ convenient.
10771093

10781094
.. versionadded:: 3.11
10791095

1080-
.. coroutinemethod:: loop.sock_connect(sock, address)
1096+
.. method:: loop.sock_connect(sock, address)
1097+
:async:
10811098

10821099
Connect *sock* to a remote socket at *address*.
10831100

@@ -1098,7 +1115,8 @@ convenient.
10981115
and :func:`asyncio.open_connection() <open_connection>`.
10991116

11001117

1101-
.. coroutinemethod:: loop.sock_accept(sock)
1118+
.. method:: loop.sock_accept(sock)
1119+
:async:
11021120

11031121
Accept a connection. Modeled after the blocking
11041122
:meth:`socket.accept() <socket.socket.accept>` method.
@@ -1120,8 +1138,9 @@ convenient.
11201138

11211139
:meth:`loop.create_server` and :func:`start_server`.
11221140

1123-
.. coroutinemethod:: loop.sock_sendfile(sock, file, offset=0, count=None, \
1124-
*, fallback=True)
1141+
.. method:: loop.sock_sendfile(sock, file, offset=0, count=None, \
1142+
*, fallback=True)
1143+
:async:
11251144
11261145
Send a file using high-performance :mod:`os.sendfile` if possible.
11271146
Return the total number of bytes sent.
@@ -1155,12 +1174,14 @@ convenient.
11551174
DNS
11561175
^^^
11571176

1158-
.. coroutinemethod:: loop.getaddrinfo(host, port, *, family=0, \
1159-
type=0, proto=0, flags=0)
1177+
.. method:: loop.getaddrinfo(host, port, *, family=0, \
1178+
type=0, proto=0, flags=0)
1179+
:async:
11601180

11611181
Asynchronous version of :meth:`socket.getaddrinfo`.
11621182

1163-
.. coroutinemethod:: loop.getnameinfo(sockaddr, flags=0)
1183+
.. method:: loop.getnameinfo(sockaddr, flags=0)
1184+
:async:
11641185

11651186
Asynchronous version of :meth:`socket.getnameinfo`.
11661187

@@ -1182,7 +1203,8 @@ DNS
11821203
Working with pipes
11831204
^^^^^^^^^^^^^^^^^^
11841205

1185-
.. coroutinemethod:: loop.connect_read_pipe(protocol_factory, pipe)
1206+
.. method:: loop.connect_read_pipe(protocol_factory, pipe)
1207+
:async:
11861208

11871209
Register the read end of *pipe* in the event loop.
11881210

@@ -1198,7 +1220,8 @@ Working with pipes
11981220
With :class:`SelectorEventLoop` event loop, the *pipe* is set to
11991221
non-blocking mode.
12001222

1201-
.. coroutinemethod:: loop.connect_write_pipe(protocol_factory, pipe)
1223+
.. method:: loop.connect_write_pipe(protocol_factory, pipe)
1224+
:async:
12021225

12031226
Register the write end of *pipe* in the event loop.
12041227

@@ -1463,9 +1486,10 @@ async/await code consider using the high-level
14631486

14641487
.. _loop_subprocess_exec:
14651488

1466-
.. coroutinemethod:: loop.subprocess_exec(protocol_factory, *args, \
1467-
stdin=subprocess.PIPE, stdout=subprocess.PIPE, \
1468-
stderr=subprocess.PIPE, **kwargs)
1489+
.. method:: loop.subprocess_exec(protocol_factory, *args, \
1490+
stdin=subprocess.PIPE, stdout=subprocess.PIPE, \
1491+
stderr=subprocess.PIPE, **kwargs)
1492+
:async:
14691493
14701494
Create a subprocess from one or more string arguments specified by
14711495
*args*.
@@ -1545,9 +1569,10 @@ async/await code consider using the high-level
15451569
conforms to the :class:`asyncio.SubprocessTransport` base class and
15461570
*protocol* is an object instantiated by the *protocol_factory*.
15471571

1548-
.. coroutinemethod:: loop.subprocess_shell(protocol_factory, cmd, *, \
1549-
stdin=subprocess.PIPE, stdout=subprocess.PIPE, \
1550-
stderr=subprocess.PIPE, **kwargs)
1572+
.. method:: loop.subprocess_shell(protocol_factory, cmd, *, \
1573+
stdin=subprocess.PIPE, stdout=subprocess.PIPE, \
1574+
stderr=subprocess.PIPE, **kwargs)
1575+
:async:
15511576
15521577
Create a subprocess from *cmd*, which can be a :class:`str` or a
15531578
:class:`bytes` string encoded to the
@@ -1692,7 +1717,8 @@ Do not instantiate the :class:`Server` class directly.
16921717

16931718
.. versionadded:: 3.7
16941719

1695-
.. coroutinemethod:: start_serving()
1720+
.. method:: start_serving()
1721+
:async:
16961722

16971723
Start accepting connections.
16981724

@@ -1708,7 +1734,8 @@ Do not instantiate the :class:`Server` class directly.
17081734

17091735
.. versionadded:: 3.7
17101736

1711-
.. coroutinemethod:: serve_forever()
1737+
.. method:: serve_forever()
1738+
:async:
17121739

17131740
Start accepting connections until the coroutine is cancelled.
17141741
Cancellation of ``serve_forever`` task causes the server
@@ -1740,7 +1767,8 @@ Do not instantiate the :class:`Server` class directly.
17401767

17411768
.. versionadded:: 3.7
17421769

1743-
.. coroutinemethod:: wait_closed()
1770+
.. method:: wait_closed()
1771+
:async:
17441772

17451773
Wait until the :meth:`close` method completes and all active
17461774
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)