-
-
Notifications
You must be signed in to change notification settings - Fork 33.9k
Clarify the docs for args in asyncio callbacks
#143873
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
akx
wants to merge
1
commit into
python:main
Choose a base branch
from
akx:add-signal-handler-docs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+12
−9
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -297,8 +297,9 @@ clocks to track time. | |
| are called is undefined. | ||
|
|
||
| The optional positional *args* will be passed to the callback when | ||
| it is called. If you want the callback to be called with keyword | ||
| arguments use :func:`functools.partial`. | ||
| it is called. You can use :func:`functools.partial` | ||
| :ref:`to pass *keyword* arguments <asyncio-pass-keywords>` to | ||
| *callback*. | ||
|
|
||
| An optional keyword-only *context* argument allows specifying a | ||
| custom :class:`contextvars.Context` for the *callback* to run in. | ||
|
|
@@ -1034,13 +1035,13 @@ Watching file descriptors | |
| .. method:: loop.add_writer(fd, callback, *args) | ||
|
|
||
| Start monitoring the *fd* file descriptor for write availability and | ||
| invoke *callback* with the specified arguments once *fd* is available for | ||
| writing. | ||
| invoke *callback* with the specified arguments *args* once *fd* is | ||
| available for writing. | ||
|
|
||
| Any preexisting callback registered for *fd* is cancelled and replaced by | ||
| *callback*. | ||
|
|
||
| Use :func:`functools.partial` :ref:`to pass keyword arguments | ||
| You can use :func:`functools.partial` :ref:`to pass *keyword* arguments | ||
| <asyncio-pass-keywords>` to *callback*. | ||
|
|
||
| .. method:: loop.remove_writer(fd) | ||
|
|
@@ -1308,7 +1309,8 @@ Unix signals | |
|
|
||
| .. method:: loop.add_signal_handler(signum, callback, *args) | ||
|
|
||
| Set *callback* as the handler for the *signum* signal. | ||
| Set *callback* as the handler for the *signum* signal, | ||
| passing *args* as positional arguments. | ||
|
|
||
| The callback will be invoked by *loop*, along with other queued callbacks | ||
| and runnable coroutines of that event loop. Unlike signal handlers | ||
|
|
@@ -1318,7 +1320,7 @@ Unix signals | |
| Raise :exc:`ValueError` if the signal number is invalid or uncatchable. | ||
| Raise :exc:`RuntimeError` if there is a problem setting up the handler. | ||
|
|
||
| Use :func:`functools.partial` :ref:`to pass keyword arguments | ||
| You can use :func:`functools.partial` :ref:`to pass *keyword* arguments | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto here. |
||
| <asyncio-pass-keywords>` to *callback*. | ||
|
|
||
| Like :func:`signal.signal`, this function must be invoked in the main | ||
|
|
@@ -1343,7 +1345,8 @@ Executing code in thread or process pools | |
|
|
||
| .. awaitablemethod:: loop.run_in_executor(executor, func, *args) | ||
|
|
||
| Arrange for *func* to be called in the specified executor. | ||
| Arrange for *func* to be called in the specified executor | ||
| with *args* being passed as positional arguments. | ||
|
|
||
| The *executor* argument should be an :class:`concurrent.futures.Executor` | ||
| instance. The default executor is used if *executor* is ``None``. | ||
|
|
@@ -1406,7 +1409,7 @@ Executing code in thread or process pools | |
|
|
||
| This method returns a :class:`asyncio.Future` object. | ||
|
|
||
| Use :func:`functools.partial` :ref:`to pass keyword arguments | ||
| You can use :func:`functools.partial` :ref:`to pass *keyword* arguments | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And here. |
||
| <asyncio-pass-keywords>` to *func*. | ||
|
|
||
| .. versionchanged:: 3.5.3 | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please avoid such rewordings, and italics should be used for parameter names.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the rewording makes it clearer (and kinder, in a sense). (What's the particular "such" here, though, so I know to avoid, well, such things in the future?)
My point for the italics was to emphasize for the reader that this is for keyword arguments, and the
*argsmechanism is already there for posargs.