[issue22473] The gloss on asyncio "future with run_forever" example is confusing
New submission from R. David Murray:
In https://docs.python.org/3/library/asyncio-task.html#example-future-with-run-... we have the sentence
In this example, the future is responsible to display the result and to stop the loop.
We could dune up the English by rewriting it:
In this example, the future is responsible for displaying the result and stopping the loop.
But that isn't quite true. It is the callback associated with the future that is displaying the result and stopping the loop. So, perhaps the correct gloss is:
In this example, the got_result callback is responsible for displaying the result and stopping the loop.
----------
assignee: docs@python
components: Documentation
messages: 227398
nosy: docs@python, r.david.murray
priority: normal
severity: normal
status: open
title: The gloss on asyncio "future with run_forever" example is confusing
type: behavior
versions: Python 3.4, Python 3.5
_______________________________________
Python tracker
Changes by Antoine Pitrou
STINNER Victor added the comment:
"But that isn't quite true. It is the callback associated with the future that is displaying the result and stopping the loop."
I wrote this example to show that setting the result of a future can schedule a callback. I mean something like:
"In this example, the future is used to link slow_operation() to got_result(): when slow_operation() is done, got_result() is called with the result."
The main idea behind Future is to chain callbacks and the link is done externally. It's different from this design:
def slow_operation(done_callback):
...
done_callback()
----------
_______________________________________
Python tracker
Changes by STINNER Victor
Roundup Robot added the comment:
New changeset a4b58e779a16 by Victor Stinner in branch '3.4':
Close #22473: asyncio doc: rephrase Future with run_forever() example
https://hg.python.org/cpython/rev/a4b58e779a16
----------
nosy: +python-dev
resolution: -> fixed
stage: -> resolved
status: open -> closed
_______________________________________
Python tracker
STINNER Victor added the comment:
I rephrase the explanation of the example and I removed the useless note. Thanks for your feedback David. Don't hesitate to propose other enhancements to the documentation!
----------
_______________________________________
Python tracker
participants (4)
-
Antoine Pitrou
-
R. David Murray
-
Roundup Robot
-
STINNER Victor