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 <rep...@bugs.python.org> <https://bugs.python.org/issue45751> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com