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: asyncio.set_running_loop() cache running loop holder
Type: Stage: resolved
Components: Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: miss-islington, tontinton, yselivanov
Priority: normal Keywords: patch

Created on 2020-07-08 19:00 by tontinton, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 21401 merged tontinton, 2020-07-08 19:06
PR 21402 merged miss-islington, 2020-07-08 19:27
PR 21403 closed miss-islington, 2020-07-08 19:28
PR 21406 merged tontinton, 2020-07-08 21:26
Messages (5)
msg373333 - (view) Author: Tony (tontinton) * Date: 2020-07-08 19:00
There is a cache variable for the running loop holder, but once set_running_loop is called the variable was set to NULL so the next time get_running_loop would have to query a dictionary to receive the running loop holder.

I thought why not always cache the latest set_running_loop?

The only issue I thought of here is in the details of the implementation: I have too little experience in python to know if there could be a context switch to get_running_loop while set_running_loop is running.

If a context switch is possible there then this issue would be way harder to solve, but it is still solvable.
msg373336 - (view) Author: miss-islington (miss-islington) Date: 2020-07-08 19:27
New changeset 529f42645d38b6b0075f256814dfb3d220ac7d92 by Tony Solomonik in branch 'master':
bpo-41247: asyncio.set_running_loop() cache running loop holder (GH-21401)
https://github.com/python/cpython/commit/529f42645d38b6b0075f256814dfb3d220ac7d92
msg373337 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2020-07-08 19:30
> n python to know if there could be a context switch to get_running_loop while set_running_loop is running.


No, it's protected by the GIL.

Good catch, and merged.
msg373340 - (view) Author: miss-islington (miss-islington) Date: 2020-07-08 19:47
New changeset fbd71f66843aea71c09656f17a196d29d5d484af by Miss Islington (bot) in branch '3.9':
bpo-41247: asyncio.set_running_loop() cache running loop holder (GH-21401)
https://github.com/python/cpython/commit/fbd71f66843aea71c09656f17a196d29d5d484af
msg373409 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2020-07-09 17:39
New changeset 0b6169e391ce6468aad711f08ffb829362293ad5 by Tony Solomonik in branch '3.8':
bpo-41247: asyncio.set_running_loop() cache running loop holder (#21406)
https://github.com/python/cpython/commit/0b6169e391ce6468aad711f08ffb829362293ad5
History
Date User Action Args
2022-04-11 14:59:33adminsetgithub: 85419
2020-07-09 17:39:05yselivanovsetmessages: + msg373409
2020-07-08 21:26:03tontintonsetpull_requests: + pull_request20555
2020-07-08 19:47:28miss-islingtonsetmessages: + msg373340
2020-07-08 19:30:41yselivanovsetstatus: open -> closed

nosy: + yselivanov
messages: + msg373337

resolution: fixed
stage: patch review -> resolved
2020-07-08 19:28:04miss-islingtonsetpull_requests: + pull_request20552
2020-07-08 19:27:52miss-islingtonsetpull_requests: + pull_request20551
2020-07-08 19:27:39miss-islingtonsetnosy: + miss-islington
messages: + msg373336
2020-07-08 19:06:39tontintonsetkeywords: + patch
stage: patch review
pull_requests: + pull_request20550
2020-07-08 19:06:04tontintonsettitle: asyncio module better caching for set and get_running_loop -> asyncio.set_running_loop() cache running loop holder
2020-07-08 19:00:14tontintoncreate