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.

classification
Title: Implement asyncio.Runner context manager
Type: Stage: resolved
Components: asyncio Versions: Python 3.11
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: asvetlov, kumaraditya, yselivanov, zach.ware
Priority: normal Keywords: patch

Created on 2022-03-18 20:44 by asvetlov, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 31799 merged asvetlov, 2022-03-18 20:45
PR 32113 merged asvetlov, 2022-03-25 12:03
Messages (5)
msg415527 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2022-03-18 20:44
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())
msg415971 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2022-03-24 19:51
New changeset 4119d2d7c9e25acd4f16994fb92d656f8b7816d7 by Andrew Svetlov in branch 'main':
bpo-47062: Implement asyncio.Runner context manager (GH-31799)
https://github.com/python/cpython/commit/4119d2d7c9e25acd4f16994fb92d656f8b7816d7
msg415990 - (view) Author: Kumar Aditya (kumaraditya) * (Python triager) Date: 2022-03-25 08:36
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.
msg416016 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2022-03-25 19:59
I believe the error is fixed by #47118
msg416021 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2022-03-25 22:26
New changeset bad6ffaa64eecd33f4320ca31b1201b25cd8fc91 by Andrew Svetlov in branch 'main':
bpo-47062: Rename factory argument to loop_factory (GH-32113)
https://github.com/python/cpython/commit/bad6ffaa64eecd33f4320ca31b1201b25cd8fc91
History
Date User Action Args
2022-04-11 14:59:57adminsetgithub: 91218
2022-03-25 22:26:35asvetlovsetmessages: + msg416021
2022-03-25 19:59:14asvetlovsetmessages: + msg416016
2022-03-25 12:03:36asvetlovsetpull_requests: + pull_request30189
2022-03-25 08:36:20kumaradityasetnosy: + kumaraditya
messages: + msg415990
2022-03-24 19:51:47asvetlovsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2022-03-24 19:51:26asvetlovsetmessages: + msg415971
2022-03-21 14:46:56zach.waresetnosy: + zach.ware
2022-03-18 20:45:28asvetlovsetkeywords: + patch
stage: patch review
pull_requests: + pull_request30075
2022-03-18 20:44:42asvetlovcreate