Skip to content
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

The gloss on asyncio "future with run_forever" example is confusing #66663

Closed
bitdancer opened this issue Sep 23, 2014 · 4 comments
Closed

The gloss on asyncio "future with run_forever" example is confusing #66663

bitdancer opened this issue Sep 23, 2014 · 4 comments
Labels
docs Documentation in the Doc dir topic-asyncio type-bug An unexpected behavior, bug, or error

Comments

@bitdancer
Copy link
Member

BPO 22473
Nosy @gvanrossum, @pitrou, @vstinner, @giampaolo, @bitdancer, @1st1

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2014-12-02.16:53:13.901>
created_at = <Date 2014-09-23.23:46:15.397>
labels = ['type-bug', 'docs', 'expert-asyncio']
title = 'The gloss on asyncio "future with run_forever" example is confusing'
updated_at = <Date 2014-12-02.16:54:03.192>
user = 'https://github.com/bitdancer'

bugs.python.org fields:

activity = <Date 2014-12-02.16:54:03.192>
actor = 'vstinner'
assignee = 'docs@python'
closed = True
closed_date = <Date 2014-12-02.16:53:13.901>
closer = 'python-dev'
components = ['Documentation', 'asyncio']
creation = <Date 2014-09-23.23:46:15.397>
creator = 'r.david.murray'
dependencies = []
files = []
hgrepos = []
issue_num = 22473
keywords = []
message_count = 4.0
messages = ['227398', '227455', '232018', '232019']
nosy_count = 8.0
nosy_names = ['gvanrossum', 'pitrou', 'vstinner', 'giampaolo.rodola', 'r.david.murray', 'docs@python', 'python-dev', 'yselivanov']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue22473'
versions = ['Python 3.4', 'Python 3.5']

@bitdancer
Copy link
Member Author

In https://docs.python.org/3/library/asyncio-task.html#example-future-with-run-forever 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.

@bitdancer bitdancer added docs Documentation in the Doc dir type-bug An unexpected behavior, bug, or error labels Sep 23, 2014
@vstinner
Copy link
Member

"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-dev
Copy link
Mannequin

python-dev mannequin commented Dec 2, 2014

New changeset a4b58e779a16 by Victor Stinner in branch '3.4':
Close bpo-22473: asyncio doc: rephrase Future with run_forever() example
https://hg.python.org/cpython/rev/a4b58e779a16

@python-dev python-dev mannequin closed this as completed Dec 2, 2014
@vstinner
Copy link
Member

vstinner commented Dec 2, 2014

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!

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir topic-asyncio type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants