[issue44407] A "Coroutines and Tasks" code example needs "asyncio.run(main())"

2021-06-15 Thread Andrei Kulakov


Andrei Kulakov  added the comment:

I think it's clear that the modification of previous example is limited to 
`main()` because `say_after()` is also omitted. This is very common in Python 
code examples, - it seems to me this change is not needed.

--
nosy: +andrei.avk

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44407] A "Coroutines and Tasks" code example needs "asyncio.run(main())"

2021-06-12 Thread Atsushi Sakai

New submission from Atsushi Sakai :

This is very small documentation improvement proposal.

In the "Coroutines and Tasks" doc, the code example after "Let’s modify the 
above example and run two say_after coroutines concurrently:" is missing 
"asyncio.run(main())" at the end of the code example:

async def main():
task1 = asyncio.create_task(
say_after(1, 'hello'))

task2 = asyncio.create_task(
say_after(2, 'world'))

print(f"started at {time.strftime('%X')}")

# Wait until both tasks are completed (should take
# around 2 seconds.)
await task1
await task2

print(f"finished at {time.strftime('%X')}")

--
assignee: docs@python
components: Documentation
messages: 395728
nosy: AtsushiSakai, docs@python
priority: normal
severity: normal
status: open
title: A "Coroutines and Tasks" code example needs "asyncio.run(main())"
type: enhancement
versions: Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com