Skip to content

Commit c49835a

Browse files
miss-islingtonakxkumaraditya303
authored
[3.13] Clarify the docs for args in asyncio callbacks (GH-143873) (#144664)
Clarify the docs for `args` in asyncio callbacks (GH-143873) (cherry picked from commit 40a82ab) Co-authored-by: Aarni Koskela <akx@iki.fi> Co-authored-by: Kumar Aditya <kumaraditya@python.org>
1 parent d177460 commit c49835a

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

Doc/library/asyncio-eventloop.rst

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,9 @@ clocks to track time.
291291
are called is undefined.
292292

293293
The optional positional *args* will be passed to the callback when
294-
it is called. If you want the callback to be called with keyword
295-
arguments use :func:`functools.partial`.
294+
it is called. Use :func:`functools.partial`
295+
:ref:`to pass keyword arguments <asyncio-pass-keywords>` to
296+
*callback*.
296297

297298
An optional keyword-only *context* argument allows specifying a
298299
custom :class:`contextvars.Context` for the *callback* to run in.
@@ -1018,8 +1019,8 @@ Watching file descriptors
10181019
.. method:: loop.add_writer(fd, callback, *args)
10191020

10201021
Start monitoring the *fd* file descriptor for write availability and
1021-
invoke *callback* with the specified arguments once *fd* is available for
1022-
writing.
1022+
invoke *callback* with the specified arguments *args* once *fd* is
1023+
available for writing.
10231024

10241025
Any preexisting callback registered for *fd* is cancelled and replaced by
10251026
*callback*.
@@ -1292,7 +1293,8 @@ Unix signals
12921293

12931294
.. method:: loop.add_signal_handler(signum, callback, *args)
12941295

1295-
Set *callback* as the handler for the *signum* signal.
1296+
Set *callback* as the handler for the *signum* signal,
1297+
passing *args* as positional arguments.
12961298

12971299
The callback will be invoked by *loop*, along with other queued callbacks
12981300
and runnable coroutines of that event loop. Unlike signal handlers
@@ -1327,7 +1329,8 @@ Executing code in thread or process pools
13271329

13281330
.. awaitablemethod:: loop.run_in_executor(executor, func, *args)
13291331

1330-
Arrange for *func* to be called in the specified executor.
1332+
Arrange for *func* to be called in the specified executor
1333+
passing *args* as positional arguments.
13311334

13321335
The *executor* argument should be an :class:`concurrent.futures.Executor`
13331336
instance. The default executor is used if *executor* is ``None``.

0 commit comments

Comments
 (0)