Skip to content

Commit 40a82ab

Browse files
akxkumaraditya303
andauthored
Clarify the docs for args in asyncio callbacks (#143873)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
1 parent ac8b5b6 commit 40a82ab

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
@@ -297,8 +297,9 @@ clocks to track time.
297297
are called is undefined.
298298

299299
The optional positional *args* will be passed to the callback when
300-
it is called. If you want the callback to be called with keyword
301-
arguments use :func:`functools.partial`.
300+
it is called. Use :func:`functools.partial`
301+
:ref:`to pass keyword arguments <asyncio-pass-keywords>` to
302+
*callback*.
302303

303304
An optional keyword-only *context* argument allows specifying a
304305
custom :class:`contextvars.Context` for the *callback* to run in.
@@ -1034,8 +1035,8 @@ Watching file descriptors
10341035
.. method:: loop.add_writer(fd, callback, *args)
10351036

10361037
Start monitoring the *fd* file descriptor for write availability and
1037-
invoke *callback* with the specified arguments once *fd* is available for
1038-
writing.
1038+
invoke *callback* with the specified arguments *args* once *fd* is
1039+
available for writing.
10391040

10401041
Any preexisting callback registered for *fd* is cancelled and replaced by
10411042
*callback*.
@@ -1308,7 +1309,8 @@ Unix signals
13081309

13091310
.. method:: loop.add_signal_handler(signum, callback, *args)
13101311

1311-
Set *callback* as the handler for the *signum* signal.
1312+
Set *callback* as the handler for the *signum* signal,
1313+
passing *args* as positional arguments.
13121314

13131315
The callback will be invoked by *loop*, along with other queued callbacks
13141316
and runnable coroutines of that event loop. Unlike signal handlers
@@ -1343,7 +1345,8 @@ Executing code in thread or process pools
13431345

13441346
.. awaitablemethod:: loop.run_in_executor(executor, func, *args)
13451347

1346-
Arrange for *func* to be called in the specified executor.
1348+
Arrange for *func* to be called in the specified executor
1349+
passing *args* as positional arguments.
13471350

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

0 commit comments

Comments
 (0)