Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement asyncio repl #81209

Closed
1st1 opened this issue May 23, 2019 · 10 comments
Closed

Implement asyncio repl #81209

1st1 opened this issue May 23, 2019 · 10 comments
Labels
3.8 only security fixes topic-asyncio

Comments

@1st1
Copy link
Member

1st1 commented May 23, 2019

BPO 37028
Nosy @vstinner, @merwok, @asvetlov, @1st1, @Carreau, @tirkarthi
PRs
  • bpo-37028: Implement asyncio REPL (activated via 'python -m asyncio') #13472
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2019-05-27.11:46:05.909>
    created_at = <Date 2019-05-23.22:57:13.335>
    labels = ['3.8', 'expert-asyncio']
    title = 'Implement asyncio repl'
    updated_at = <Date 2020-05-28.00:18:11.485>
    user = 'https://github.com/1st1'

    bugs.python.org fields:

    activity = <Date 2020-05-28.00:18:11.485>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2019-05-27.11:46:05.909>
    closer = 'yselivanov'
    components = ['asyncio']
    creation = <Date 2019-05-23.22:57:13.335>
    creator = 'yselivanov'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 37028
    keywords = ['patch']
    message_count = 8.0
    messages = ['343334', '343615', '343616', '343630', '343637', '370118', '370132', '370157']
    nosy_count = 6.0
    nosy_names = ['vstinner', 'eric.araujo', 'asvetlov', 'yselivanov', 'mbussonn', 'xtreak']
    pr_nums = ['13472']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue37028'
    versions = ['Python 3.8']

    @1st1
    Copy link
    Member Author

    1st1 commented May 23, 2019

    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

    @1st1 1st1 added 3.8 only security fixes topic-asyncio labels May 23, 2019
    @1st1
    Copy link
    Member Author

    1st1 commented May 27, 2019

    New changeset 16cefb0 by Yury Selivanov in branch 'master':
    bpo-37028: asyncio REPL; activated via 'python -m asyncio'. (GH-13472)
    16cefb0

    @1st1
    Copy link
    Member Author

    1st1 commented May 27, 2019

    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.

    @1st1 1st1 closed this as completed May 27, 2019
    @vstinner
    Copy link
    Member

    "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...".

    @1st1
    Copy link
    Member Author

    1st1 commented May 27, 2019

    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)

    @merwok
    Copy link
    Member

    merwok commented May 27, 2020

    Compared to the vanilla REPL, this doesn’t include readline setup for tab completion and history file. Was it on purpose?

    @Carreau
    Copy link
    Mannequin

    Carreau mannequin commented May 27, 2020

    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.

    @vstinner
    Copy link
    Member

    vstinner commented May 28, 2020

    This issue is now closed. If someone wants to enhance the asyncio REPL, please open a new issue.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    @rinarakaki
    Copy link

    Is this feature related to pdb? I'm trying to use top-level await in pdb where I set breakpoint().

    @merwok
    Copy link
    Member

    merwok commented Oct 17, 2023

    It’s not

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.8 only security fixes topic-asyncio
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants