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.Runner context manager #91218

Closed
asvetlov opened this issue Mar 18, 2022 · 7 comments
Closed

Implement asyncio.Runner context manager #91218

asvetlov opened this issue Mar 18, 2022 · 7 comments
Labels
3.11 only security fixes topic-asyncio

Comments

@asvetlov
Copy link
Contributor

BPO 47062
Nosy @asvetlov, @zware, @1st1, @kumaraditya303
PRs
  • bpo-47062: Implement asyncio.Runner context manager #31799
  • bpo-47062: Rename factory argument to loop_factory #32113
  • 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 2022-03-24.19:51:47.800>
    created_at = <Date 2022-03-18.20:44:42.359>
    labels = ['3.11', 'expert-asyncio']
    title = 'Implement asyncio.Runner context manager'
    updated_at = <Date 2022-03-25.22:26:35.045>
    user = 'https://github.com/asvetlov'

    bugs.python.org fields:

    activity = <Date 2022-03-25.22:26:35.045>
    actor = 'asvetlov'
    assignee = 'none'
    closed = True
    closed_date = <Date 2022-03-24.19:51:47.800>
    closer = 'asvetlov'
    components = ['asyncio']
    creation = <Date 2022-03-18.20:44:42.359>
    creator = 'asvetlov'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 47062
    keywords = ['patch']
    message_count = 5.0
    messages = ['415527', '415971', '415990', '416016', '416021']
    nosy_count = 4.0
    nosy_names = ['asvetlov', 'zach.ware', 'yselivanov', 'kumaraditya']
    pr_nums = ['31799', '32113']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue47062'
    versions = ['Python 3.11']

    @asvetlov
    Copy link
    Contributor Author

    Sometimes asyncio.run() is not enough.

    For example, unittest test case needs to call several async functions (setup, test, teardown) from the synchronous code using the same execution context and event loop.

    The proposal provides the following:

    with Runner() as runner:
      runner.run(async_func())

    @asvetlov asvetlov added 3.11 only security fixes topic-asyncio labels Mar 18, 2022
    @asvetlov
    Copy link
    Contributor Author

    New changeset 4119d2d by Andrew Svetlov in branch 'main':
    bpo-47062: Implement asyncio.Runner context manager (GH-31799)
    4119d2d

    @kumaraditya303
    Copy link
    Contributor

    With this change, Github Actions fails first time and it passes in the second rerun of running asyncio tests.

    See https://github.com/python/cpython/runs/5682275663?check_suite_focus=true and main branch.

    @asvetlov
    Copy link
    Contributor Author

    I believe the error is fixed by bpo-47118

    @asvetlov
    Copy link
    Contributor Author

    New changeset bad6ffa by Andrew Svetlov in branch 'main':
    bpo-47062: Rename factory argument to loop_factory (GH-32113)
    bad6ffa

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

    encukou commented Jun 2, 2022

    It seems that this commit broke tests in aiohttp: aio-libs/aiohttp#6757 (comment)

    @graingert
    Copy link
    Contributor

    @encukou I have an issue here #93896 and a PR here #94058

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

    No branches or pull requests

    4 participants