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.

Title: Support AutoAwait?
Type: Stage: resolved
Components: asyncio, Interpreter Core Versions: Python 3.8
Status: closed Resolution: duplicate
Dependencies: Superseder: implement "Async exec"
View: 34616
Assigned To: Nosy List: asvetlov, gvanrossum, xtreak, yselivanov
Priority: normal Keywords:

Created on 2019-03-25 23:49 by gvanrossum, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (4)
msg338840 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2019-03-25 23:49
I just found out about IPython's autoawait feature:

I wonder if we should at least help them do this right in Python 3.8 by having a flag to compile() that allows `await` in the toplevel syntax? It looks like a relatively small change would suffice to make compiler_visit_expr1() in Python/compile.c accept (and generate correct code for) Await_kind outside async functions, if some flag is set.
msg338841 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2019-03-25 23:50
Absolutely. I think there's another open issue for this and I even have a dev branch somewhere with this idea half implemented.  Definitely something to have in 3.8.
msg338842 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2019-03-26 00:03
I think this is same as issue34616 . The issue talks about the workarounds IPython has to use for the feature and links to the PR where it was implemented . I never knew about this feature and this will be very helpful to have especially it reduces boilerplate in having async functions for await calls though improved setting up loop part. Helps in playing around with API in repl during learning with top level await expressions allowed in repl.
msg338843 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2019-03-26 00:05
Oh, you're right. Thanks! Closing in favor of issue34616.
Date User Action Args
2022-04-11 14:59:13adminsetgithub: 80609
2019-03-26 00:09:01xtreaksetsuperseder: implement "Async exec"
2019-03-26 00:05:56gvanrossumsetstatus: open -> closed
resolution: duplicate
messages: + msg338843

stage: resolved
2019-03-26 00:03:32xtreaksetnosy: + xtreak
messages: + msg338842
2019-03-25 23:50:59yselivanovsetmessages: + msg338841
2019-03-25 23:49:29gvanrossumcreate