Skip to content

Commit 36ecbfb

Browse files
sobolevnAA-Turner
andcommitted
[3.12] pythongh-121970: Replace .. coroutine{method,function} with :async: (pythonGH-130448)
(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 6c59ea6 commit 36ecbfb

10 files changed

+186
-141
lines changed

Diff for: Doc/library/asyncio-eventloop.rst

+86-59
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,15 +673,15 @@ 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, \
675680
sock=None, backlog=100, ssl=None, \
676681
reuse_address=None, reuse_port=None, \
677682
ssl_handshake_timeout=None, \
678683
ssl_shutdown_timeout=None, \
679-
start_serving=True)
684+
start_serving=True):async:
680685
681686
Create a TCP server (socket type :const:`~socket.SOCK_STREAM`) listening
682687
on *port* of the *host* address.
@@ -777,11 +782,12 @@ Creating network servers
777782
that can be used in an async/await code.
778783

779784

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)
785+
.. method:: loop.create_unix_server(protocol_factory, path=None, \
786+
*, sock=None, backlog=100, ssl=None, \
787+
ssl_handshake_timeout=None, \
788+
ssl_shutdown_timeout=None, \
789+
start_serving=True)
790+
:async:
785791
786792
Similar to :meth:`loop.create_server` but works with the
787793
:py:const:`~socket.AF_UNIX` socket family.
@@ -806,9 +812,10 @@ Creating network servers
806812
Added the *ssl_shutdown_timeout* parameter.
807813

808814

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

@@ -856,8 +863,9 @@ Creating network servers
856863
Transferring files
857864
^^^^^^^^^^^^^^^^^^
858865

859-
.. coroutinemethod:: loop.sendfile(transport, file, \
860-
offset=0, count=None, *, fallback=True)
866+
.. method:: loop.sendfile(transport, file, \
867+
offset=0, count=None, *, fallback=True)
868+
:async:
861869
862870
Send a *file* over a *transport*. Return the total number of bytes
863871
sent.
@@ -886,10 +894,11 @@ Transferring files
886894
TLS Upgrade
887895
^^^^^^^^^^^
888896

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)
897+
.. method:: loop.start_tls(transport, protocol, \
898+
sslcontext, *, server_side=False, \
899+
server_hostname=None, ssl_handshake_timeout=None, \
900+
ssl_shutdown_timeout=None)
901+
:async:
893902
894903
Upgrade an existing transport-based connection to TLS.
895904

@@ -983,7 +992,8 @@ However, there are some use cases when performance is not critical, and
983992
working with :class:`~socket.socket` objects directly is more
984993
convenient.
985994

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

988998
Receive up to *nbytes* from *sock*. Asynchronous version of
989999
:meth:`socket.recv() <socket.socket.recv>`.
@@ -997,7 +1007,8 @@ convenient.
9971007
method, releases before Python 3.7 returned a :class:`Future`.
9981008
Since Python 3.7 this is an ``async def`` method.
9991009

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

10021013
Receive data from *sock* into the *buf* buffer. Modeled after the blocking
10031014
:meth:`socket.recv_into() <socket.socket.recv_into>` method.
@@ -1008,7 +1019,8 @@ convenient.
10081019

10091020
.. versionadded:: 3.7
10101021

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

10131025
Receive a datagram of up to *bufsize* from *sock*. Asynchronous version of
10141026
:meth:`socket.recvfrom() <socket.socket.recvfrom>`.
@@ -1019,7 +1031,8 @@ convenient.
10191031

10201032
.. versionadded:: 3.11
10211033

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

10241037
Receive a datagram of up to *nbytes* from *sock* into *buf*.
10251038
Asynchronous version of
@@ -1031,7 +1044,8 @@ convenient.
10311044

10321045
.. versionadded:: 3.11
10331046

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

10361050
Send *data* to the *sock* socket. Asynchronous version of
10371051
:meth:`socket.sendall() <socket.socket.sendall>`.
@@ -1049,7 +1063,8 @@ convenient.
10491063
method, before Python 3.7 it returned a :class:`Future`.
10501064
Since Python 3.7, this is an ``async def`` method.
10511065

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

10541069
Send a datagram from *sock* to *address*.
10551070
Asynchronous version of
@@ -1061,7 +1076,8 @@ convenient.
10611076

10621077
.. versionadded:: 3.11
10631078

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

10661082
Connect *sock* to a remote socket at *address*.
10671083

@@ -1082,7 +1098,8 @@ convenient.
10821098
and :func:`asyncio.open_connection() <open_connection>`.
10831099

10841100

1085-
.. coroutinemethod:: loop.sock_accept(sock)
1101+
.. method:: loop.sock_accept(sock)
1102+
:async:
10861103

10871104
Accept a connection. Modeled after the blocking
10881105
:meth:`socket.accept() <socket.socket.accept>` method.
@@ -1104,8 +1121,9 @@ convenient.
11041121

11051122
:meth:`loop.create_server` and :func:`start_server`.
11061123

1107-
.. coroutinemethod:: loop.sock_sendfile(sock, file, offset=0, count=None, \
1108-
*, fallback=True)
1124+
.. method:: loop.sock_sendfile(sock, file, offset=0, count=None, \
1125+
*, fallback=True)
1126+
:async:
11091127
11101128
Send a file using high-performance :mod:`os.sendfile` if possible.
11111129
Return the total number of bytes sent.
@@ -1139,12 +1157,14 @@ convenient.
11391157
DNS
11401158
^^^
11411159

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

11451164
Asynchronous version of :meth:`socket.getaddrinfo`.
11461165

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

11491169
Asynchronous version of :meth:`socket.getnameinfo`.
11501170

@@ -1166,7 +1186,8 @@ DNS
11661186
Working with pipes
11671187
^^^^^^^^^^^^^^^^^^
11681188

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

11711192
Register the read end of *pipe* in the event loop.
11721193

@@ -1182,7 +1203,8 @@ Working with pipes
11821203
With :class:`SelectorEventLoop` event loop, the *pipe* is set to
11831204
non-blocking mode.
11841205

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

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

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

14481470
.. _loop_subprocess_exec:
14491471

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

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

16521676
.. versionadded:: 3.7
16531677

1654-
.. coroutinemethod:: start_serving()
1678+
.. method:: start_serving()
1679+
:async:
16551680

16561681
Start accepting connections.
16571682

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

16681693
.. versionadded:: 3.7
16691694

1670-
.. coroutinemethod:: serve_forever()
1695+
.. method:: serve_forever()
1696+
:async:
16711697

16721698
Start accepting connections until the coroutine is cancelled.
16731699
Cancellation of ``serve_forever`` task causes the server
@@ -1699,7 +1725,8 @@ Do not instantiate the :class:`Server` class directly.
16991725

17001726
.. versionadded:: 3.7
17011727

1702-
.. coroutinemethod:: wait_closed()
1728+
.. method:: wait_closed()
1729+
:async:
17031730

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

Diff for: 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)