Skip to content

Commit 4b8658a

Browse files
committed
Clarify the docs for args in asyncio callbacks
1 parent 3514ba2 commit 4b8658a

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

Doc/library/asyncio-eventloop.rst

Lines changed: 12 additions & 9 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. You can 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,13 +1035,13 @@ 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*.
10421043

1043-
Use :func:`functools.partial` :ref:`to pass keyword arguments
1044+
You can use :func:`functools.partial` :ref:`to pass *keyword* arguments
10441045
<asyncio-pass-keywords>` to *callback*.
10451046

10461047
.. method:: loop.remove_writer(fd)
@@ -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
@@ -1318,7 +1320,7 @@ Unix signals
13181320
Raise :exc:`ValueError` if the signal number is invalid or uncatchable.
13191321
Raise :exc:`RuntimeError` if there is a problem setting up the handler.
13201322

1321-
Use :func:`functools.partial` :ref:`to pass keyword arguments
1323+
You can use :func:`functools.partial` :ref:`to pass *keyword* arguments
13221324
<asyncio-pass-keywords>` to *callback*.
13231325

13241326
Like :func:`signal.signal`, this function must be invoked in the main
@@ -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+
with *args* being passed 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``.
@@ -1406,7 +1409,7 @@ Executing code in thread or process pools
14061409

14071410
This method returns a :class:`asyncio.Future` object.
14081411

1409-
Use :func:`functools.partial` :ref:`to pass keyword arguments
1412+
You can use :func:`functools.partial` :ref:`to pass *keyword* arguments
14101413
<asyncio-pass-keywords>` to *func*.
14111414

14121415
.. versionchanged:: 3.5.3

0 commit comments

Comments
 (0)