Skip to content

Commit 9bd92fa

Browse files
AA-Turnersobolevn
andauthored
[3.12] gh-121970: Replace .. coroutine{method,function} with :async: (GH-130448) (#130467)
(cherry picked from commit 5ec4bf8) Co-authored-by: sobolevn <mail@sobolevn.me>
1 parent 6c59ea6 commit 9bd92fa

10 files changed

+187
-140
lines changed

Doc/library/asyncio-eventloop.rst

+86-58
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,7 +673,7 @@ Creating network servers
668673

669674
.. _loop_create_server:
670675

671-
.. coroutinemethod:: loop.create_server(protocol_factory, \
676+
.. method:: loop.create_server(protocol_factory, \
672677
host=None, port=None, *, \
673678
family=socket.AF_UNSPEC, \
674679
flags=socket.AI_PASSIVE, \
@@ -677,6 +682,7 @@ Creating network servers
677682
ssl_handshake_timeout=None, \
678683
ssl_shutdown_timeout=None, \
679684
start_serving=True)
685+
:async:
680686
681687
Create a TCP server (socket type :const:`~socket.SOCK_STREAM`) listening
682688
on *port* of the *host* address.
@@ -777,11 +783,12 @@ Creating network servers
777783
that can be used in an async/await code.
778784

779785

780-
.. coroutinemethod:: loop.create_unix_server(protocol_factory, path=None, \
781-
*, sock=None, backlog=100, ssl=None, \
782-
ssl_handshake_timeout=None, \
783-
ssl_shutdown_timeout=None, \
784-
start_serving=True)
786+
.. method:: loop.create_unix_server(protocol_factory, path=None, \
787+
*, sock=None, backlog=100, ssl=None, \
788+
ssl_handshake_timeout=None, \
789+
ssl_shutdown_timeout=None, \
790+
start_serving=True)
791+
:async:
785792
786793
Similar to :meth:`loop.create_server` but works with the
787794
:py:const:`~socket.AF_UNIX` socket family.
@@ -806,9 +813,10 @@ Creating network servers
806813
Added the *ssl_shutdown_timeout* parameter.
807814

808815

809-
.. coroutinemethod:: loop.connect_accepted_socket(protocol_factory, \
810-
sock, *, ssl=None, ssl_handshake_timeout=None, \
811-
ssl_shutdown_timeout=None)
816+
.. method:: loop.connect_accepted_socket(protocol_factory, \
817+
sock, *, ssl=None, ssl_handshake_timeout=None, \
818+
ssl_shutdown_timeout=None)
819+
:async:
812820
813821
Wrap an already accepted connection into a transport/protocol pair.
814822

@@ -856,8 +864,9 @@ Creating network servers
856864
Transferring files
857865
^^^^^^^^^^^^^^^^^^
858866

859-
.. coroutinemethod:: loop.sendfile(transport, file, \
860-
offset=0, count=None, *, fallback=True)
867+
.. method:: loop.sendfile(transport, file, \
868+
offset=0, count=None, *, fallback=True)
869+
:async:
861870
862871
Send a *file* over a *transport*. Return the total number of bytes
863872
sent.
@@ -886,10 +895,11 @@ Transferring files
886895
TLS Upgrade
887896
^^^^^^^^^^^
888897

889-
.. coroutinemethod:: loop.start_tls(transport, protocol, \
890-
sslcontext, *, server_side=False, \
891-
server_hostname=None, ssl_handshake_timeout=None, \
892-
ssl_shutdown_timeout=None)
898+
.. method:: loop.start_tls(transport, protocol, \
899+
sslcontext, *, server_side=False, \
900+
server_hostname=None, ssl_handshake_timeout=None, \
901+
ssl_shutdown_timeout=None)
902+
:async:
893903
894904
Upgrade an existing transport-based connection to TLS.
895905

@@ -983,7 +993,8 @@ However, there are some use cases when performance is not critical, and
983993
working with :class:`~socket.socket` objects directly is more
984994
convenient.
985995

986-
.. coroutinemethod:: loop.sock_recv(sock, nbytes)
996+
.. method:: loop.sock_recv(sock, nbytes)
997+
:async:
987998

988999
Receive up to *nbytes* from *sock*. Asynchronous version of
9891000
:meth:`socket.recv() <socket.socket.recv>`.
@@ -997,7 +1008,8 @@ convenient.
9971008
method, releases before Python 3.7 returned a :class:`Future`.
9981009
Since Python 3.7 this is an ``async def`` method.
9991010

1000-
.. coroutinemethod:: loop.sock_recv_into(sock, buf)
1011+
.. method:: loop.sock_recv_into(sock, buf)
1012+
:async:
10011013

10021014
Receive data from *sock* into the *buf* buffer. Modeled after the blocking
10031015
:meth:`socket.recv_into() <socket.socket.recv_into>` method.
@@ -1008,7 +1020,8 @@ convenient.
10081020

10091021
.. versionadded:: 3.7
10101022

1011-
.. coroutinemethod:: loop.sock_recvfrom(sock, bufsize)
1023+
.. method:: loop.sock_recvfrom(sock, bufsize)
1024+
:async:
10121025

10131026
Receive a datagram of up to *bufsize* from *sock*. Asynchronous version of
10141027
:meth:`socket.recvfrom() <socket.socket.recvfrom>`.
@@ -1019,7 +1032,8 @@ convenient.
10191032

10201033
.. versionadded:: 3.11
10211034

1022-
.. coroutinemethod:: loop.sock_recvfrom_into(sock, buf, nbytes=0)
1035+
.. method:: loop.sock_recvfrom_into(sock, buf, nbytes=0)
1036+
:async:
10231037

10241038
Receive a datagram of up to *nbytes* from *sock* into *buf*.
10251039
Asynchronous version of
@@ -1031,7 +1045,8 @@ convenient.
10311045

10321046
.. versionadded:: 3.11
10331047

1034-
.. coroutinemethod:: loop.sock_sendall(sock, data)
1048+
.. method:: loop.sock_sendall(sock, data)
1049+
:async:
10351050

10361051
Send *data* to the *sock* socket. Asynchronous version of
10371052
:meth:`socket.sendall() <socket.socket.sendall>`.
@@ -1049,7 +1064,8 @@ convenient.
10491064
method, before Python 3.7 it returned a :class:`Future`.
10501065
Since Python 3.7, this is an ``async def`` method.
10511066

1052-
.. coroutinemethod:: loop.sock_sendto(sock, data, address)
1067+
.. method:: loop.sock_sendto(sock, data, address)
1068+
:async:
10531069

10541070
Send a datagram from *sock* to *address*.
10551071
Asynchronous version of
@@ -1061,7 +1077,8 @@ convenient.
10611077

10621078
.. versionadded:: 3.11
10631079

1064-
.. coroutinemethod:: loop.sock_connect(sock, address)
1080+
.. method:: loop.sock_connect(sock, address)
1081+
:async:
10651082

10661083
Connect *sock* to a remote socket at *address*.
10671084

@@ -1082,7 +1099,8 @@ convenient.
10821099
and :func:`asyncio.open_connection() <open_connection>`.
10831100

10841101

1085-
.. coroutinemethod:: loop.sock_accept(sock)
1102+
.. method:: loop.sock_accept(sock)
1103+
:async:
10861104

10871105
Accept a connection. Modeled after the blocking
10881106
:meth:`socket.accept() <socket.socket.accept>` method.
@@ -1104,8 +1122,9 @@ convenient.
11041122

11051123
:meth:`loop.create_server` and :func:`start_server`.
11061124

1107-
.. coroutinemethod:: loop.sock_sendfile(sock, file, offset=0, count=None, \
1108-
*, fallback=True)
1125+
.. method:: loop.sock_sendfile(sock, file, offset=0, count=None, \
1126+
*, fallback=True)
1127+
:async:
11091128
11101129
Send a file using high-performance :mod:`os.sendfile` if possible.
11111130
Return the total number of bytes sent.
@@ -1139,12 +1158,14 @@ convenient.
11391158
DNS
11401159
^^^
11411160

1142-
.. coroutinemethod:: loop.getaddrinfo(host, port, *, family=0, \
1143-
type=0, proto=0, flags=0)
1161+
.. method:: loop.getaddrinfo(host, port, *, family=0, \
1162+
type=0, proto=0, flags=0)
1163+
:async:
11441164

11451165
Asynchronous version of :meth:`socket.getaddrinfo`.
11461166

1147-
.. coroutinemethod:: loop.getnameinfo(sockaddr, flags=0)
1167+
.. method:: loop.getnameinfo(sockaddr, flags=0)
1168+
:async:
11481169

11491170
Asynchronous version of :meth:`socket.getnameinfo`.
11501171

@@ -1166,7 +1187,8 @@ DNS
11661187
Working with pipes
11671188
^^^^^^^^^^^^^^^^^^
11681189

1169-
.. coroutinemethod:: loop.connect_read_pipe(protocol_factory, pipe)
1190+
.. method:: loop.connect_read_pipe(protocol_factory, pipe)
1191+
:async:
11701192

11711193
Register the read end of *pipe* in the event loop.
11721194

@@ -1182,7 +1204,8 @@ Working with pipes
11821204
With :class:`SelectorEventLoop` event loop, the *pipe* is set to
11831205
non-blocking mode.
11841206

1185-
.. coroutinemethod:: loop.connect_write_pipe(protocol_factory, pipe)
1207+
.. method:: loop.connect_write_pipe(protocol_factory, pipe)
1208+
:async:
11861209

11871210
Register the write end of *pipe* in the event loop.
11881211

@@ -1447,9 +1470,10 @@ async/await code consider using the high-level
14471470

14481471
.. _loop_subprocess_exec:
14491472

1450-
.. coroutinemethod:: loop.subprocess_exec(protocol_factory, *args, \
1451-
stdin=subprocess.PIPE, stdout=subprocess.PIPE, \
1452-
stderr=subprocess.PIPE, **kwargs)
1473+
.. method:: loop.subprocess_exec(protocol_factory, *args, \
1474+
stdin=subprocess.PIPE, stdout=subprocess.PIPE, \
1475+
stderr=subprocess.PIPE, **kwargs)
1476+
:async:
14531477
14541478
Create a subprocess from one or more string arguments specified by
14551479
*args*.
@@ -1529,9 +1553,10 @@ async/await code consider using the high-level
15291553
conforms to the :class:`asyncio.SubprocessTransport` base class and
15301554
*protocol* is an object instantiated by the *protocol_factory*.
15311555

1532-
.. coroutinemethod:: loop.subprocess_shell(protocol_factory, cmd, *, \
1533-
stdin=subprocess.PIPE, stdout=subprocess.PIPE, \
1534-
stderr=subprocess.PIPE, **kwargs)
1556+
.. method:: loop.subprocess_shell(protocol_factory, cmd, *, \
1557+
stdin=subprocess.PIPE, stdout=subprocess.PIPE, \
1558+
stderr=subprocess.PIPE, **kwargs)
1559+
:async:
15351560
15361561
Create a subprocess from *cmd*, which can be a :class:`str` or a
15371562
:class:`bytes` string encoded to the
@@ -1651,7 +1676,8 @@ Do not instantiate the :class:`Server` class directly.
16511676

16521677
.. versionadded:: 3.7
16531678

1654-
.. coroutinemethod:: start_serving()
1679+
.. method:: start_serving()
1680+
:async:
16551681

16561682
Start accepting connections.
16571683

@@ -1667,7 +1693,8 @@ Do not instantiate the :class:`Server` class directly.
16671693

16681694
.. versionadded:: 3.7
16691695

1670-
.. coroutinemethod:: serve_forever()
1696+
.. method:: serve_forever()
1697+
:async:
16711698

16721699
Start accepting connections until the coroutine is cancelled.
16731700
Cancellation of ``serve_forever`` task causes the server
@@ -1699,7 +1726,8 @@ Do not instantiate the :class:`Server` class directly.
16991726

17001727
.. versionadded:: 3.7
17011728

1702-
.. coroutinemethod:: wait_closed()
1729+
.. method:: wait_closed()
1730+
:async:
17031731

17041732
Wait until the :meth:`close` method completes and all active
17051733
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.
@@ -67,7 +68,8 @@ Queue
6768
Return an item if one is immediately available, else raise
6869
:exc:`QueueEmpty`.
6970

70-
.. coroutinemethod:: join()
71+
.. method:: join()
72+
:async:
7173

7274
Block until all items in the queue have been received and processed.
7375

@@ -77,7 +79,8 @@ Queue
7779
work on it is complete. When the count of unfinished tasks drops
7880
to zero, :meth:`join` unblocks.
7981

80-
.. coroutinemethod:: put(item)
82+
.. method:: put(item)
83+
:async:
8184

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

0 commit comments

Comments
 (0)