classification
Title: Implement asyncio repl
Type: Stage: resolved
Components: asyncio Versions: Python 3.8
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: asvetlov, eric.araujo, mbussonn, vstinner, xtreak, yselivanov
Priority: normal Keywords: patch

Created on 2019-05-23 22:57 by yselivanov, last changed 2020-05-28 00:18 by vstinner. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 13472 merged yselivanov, 2019-05-23 22:58
Messages (8)
msg343334 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2019-05-23 22:57
Having an asyncio enabled repr where a top-level "await" possible would be a huge productivity boost.  Using asyncio.run() in a REPL is hard, and besides it spawns a new event loop on every call.

The big idea: we want users to be able to do this:

    $ python -m asyncio

    >>> await asyncio.sleep(10, return='hello')
    # after 10 seconds
    hello
msg343615 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2019-05-27 11:42
New changeset 16cefb0bc7b05c08caf08525398ff178c35dece4 by Yury Selivanov in branch 'master':
bpo-37028: asyncio REPL; activated via 'python -m asyncio'. (GH-13472)
https://github.com/python/cpython/commit/16cefb0bc7b05c08caf08525398ff178c35dece4
msg343616 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2019-05-27 11:46
The REPL has been merged to 3.8.  It's not perfect though -- a ^C might break the asyncio event loop, sometimes ^C stops working altogether.  We'll investigate all these issues in follow up PRs.
msg343630 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-05-27 14:30
"asyncio REPL 3.8.0a4+ (heads/pep587_rename-dirty:ae29b4b186, May 27 2019, 16:10:31)"

I suggest "Python asyncio REPL 3.8.0a4+ (...)". I prefer to keep "Python" somewhere.

Is "exiting asyncio REPL..." message really helpful? If exit can block, would it possible to only display a message if something "hangs" (takes time)? I would expect something like "Waiting for xxx completion for 1 second...".
msg343637 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2019-05-27 15:08
> I suggest "Python asyncio REPL 3.8.0a4+ (...)". I prefer to keep "Python" somewhere.

Sure.

> Is "exiting asyncio REPL..." message really helpful? If exit can block, would it possible to only display a message if something "hangs" (takes time)? I would expect something like "Waiting for xxx completion for 1 second...".

NP, I can drop the message.  The waiting part isn't necessary, since we don't try to shutdown the loop properly anyways (yet)
msg370118 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2020-05-27 18:36
Compared to the vanilla REPL, this doesn’t include readline setup for tab completion and history file.  Was it on purpose?
msg370132 - (view) Author: Matthias Bussonnier (mbussonn) * Date: 2020-05-27 20:44
> Compared to the vanilla REPL, this doesn’t include readline setup for tab completion and history file.  Was it on purpose?

Not particularly, it was mostly to show it is possible. I'm guessing any improvement to make it more consistent with the normal REPL would be welcome. 

If you want a fancier repl that also have these features it should work out of the box with IPython.
msg370157 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-05-28 00:18
This issue is now closed. If someone wants to enhane the asyncio REPL, please open a new issue.
History
Date User Action Args
2020-05-28 00:18:11vstinnersetresolution: fixed
messages: + msg370157
2020-05-27 20:44:41mbussonnsetmessages: + msg370132
2020-05-27 18:36:31eric.araujosetnosy: + eric.araujo
messages: + msg370118
2019-05-27 15:08:30yselivanovsetmessages: + msg343637
2019-05-27 14:30:07vstinnersetnosy: + vstinner
messages: + msg343630
2019-05-27 11:46:05yselivanovsetstatus: open -> closed

messages: + msg343616
stage: patch review -> resolved
2019-05-27 11:42:45yselivanovsetmessages: + msg343615
2019-05-24 01:17:18xtreaksetnosy: + xtreak
2019-05-23 23:05:43mbussonnsetnosy: + mbussonn
2019-05-23 22:58:01yselivanovsetkeywords: + patch
stage: patch review
pull_requests: + pull_request13446
2019-05-23 22:57:13yselivanovcreate