This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: documentation bad on asyncio
Type: Stage: resolved
Components: asyncio Versions: Python 3.9
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: aeros, asvetlov, cnd, yselivanov
Priority: normal Keywords:

Created on 2020-05-06 04:06 by cnd, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (3)
msg368223 - (view) Author: Chris Drake (cnd) Date: 2020-05-06 04:06
> The sample on this page is not demonstrating anything asynchronous:
> https://docs.python.org/3/library/asyncio.html

Put something that is relevant please.  e.g.

import asyncio
import time

async def say_after(delay, what):
    await asyncio.sleep(delay)
    print(what)

async def main():
    print(f"started at {time.strftime('%X')}")
    await say_after(2, 'world')
    await say_after(1, 'hello')
    print(f"finished at {time.strftime('%X')}")

asyncio.run(main())
msg368229 - (view) Author: Kyle Stanley (aeros) * (Python committer) Date: 2020-05-06 05:49
I presume this is referring to the following example on the first page of the docs:

```
import asyncio

async def main():
    print('Hello ...')
    await asyncio.sleep(1)
    print('... World!')

# Python 3.7+
asyncio.run(main())
```

If so, the main purpose of that example is just to demonstrate basic async/await syntax, and show asyncio.run() for a trivial case to clearly show how it's used at a fundamental level; it's intentional that the more involved examples that demonstrate asynchronous programming are contained in https://docs.python.org/3/library/asyncio-task.html#coroutine. Also, the example is simple and condensed enough that it requires zero additional explanation or context, as should be the case for a simple "hello world" example. Consider the perspective of someone who found the page without having previously seen async/await syntax used.

FYI, in the future, I would highly recommend focusing more on the constructive parts when opening issues. Particularly the title "documentation bad on asyncio", provides zero context or usefulness. It also comes across as rather rude and unappreciative of the significant voluntary efforts that went into writing the documentation in the first place. Instead, something like "Improve example on front page of asyncio docs" is much more helpful.
msg368287 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2020-05-06 18:01
> If so, the main purpose of that example is just to demonstrate basic async/await syntax, and show asyncio.run() for a trivial case to clearly show how it's used at a fundamental level; it's intentional that the more involved examples that demonstrate asynchronous programming are contained in https://docs.python.org/3/library/asyncio-task.html#coroutine. Also, the example is simple and condensed enough that it requires zero additional explanation or context, as should be the case for a simple "hello world" example. Consider the perspective of someone who found the page without having previously seen async/await syntax used.

Yes, exactly.
History
Date User Action Args
2022-04-11 14:59:30adminsetgithub: 84706
2020-05-06 18:01:32yselivanovsetstatus: open -> closed
resolution: not a bug
messages: + msg368287

stage: resolved
2020-05-06 05:49:00aerossetnosy: + aeros
messages: + msg368229
2020-05-06 04:06:03cndcreate