[New-bugs-announce] [issue45751] "SyntaxError: 'await' outside function" in "asyncio-task.html#waiting-primitives" code snippets
Jose Ville
report at bugs.python.org
Mon Nov 8 11:47:59 EST 2021
New submission from Jose Ville <joseville>:
https://docs.python.org/3/library/asyncio-task.html#asyncio.wait has the following two code snippets both of which fail with ""SyntaxError: 'await' outside function" when I run them in Python 3.9.7
Snippet 1:
```
async def foo():
return 42
coro = foo()
done, pending = await asyncio.wait({coro})
if coro in done:
# This branch will never be run!
pass # I added this to prevent IndentationError
```
Snippet 2:
```
async def foo():
return 42
task = asyncio.create_task(foo())
done, pending = await asyncio.wait({task})
if task in done:
# Everything will work as expected now.
pass # I added this to prevent IndentationError
```
----------
components: asyncio
messages: 405960
nosy: asvetlov, joseville, yselivanov
priority: normal
severity: normal
status: open
title: "SyntaxError: 'await' outside function" in "asyncio-task.html#waiting-primitives" code snippets
type: compile error
versions: Python 3.9
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45751>
_______________________________________
More information about the New-bugs-announce
mailing list