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

asyncio.set_running_loop() cache running loop holder #85419

Closed
tontinton mannequin opened this issue Jul 8, 2020 · 5 comments
Closed

asyncio.set_running_loop() cache running loop holder #85419

tontinton mannequin opened this issue Jul 8, 2020 · 5 comments

Comments

@tontinton
Copy link
Mannequin

tontinton mannequin commented Jul 8, 2020

BPO 41247
Nosy @1st1, @miss-islington, @tontinton
PRs
  • bpo-41247: asyncio.set_running_loop() cache running loop holder #21401
  • [3.9] bpo-41247: asyncio.set_running_loop() cache running loop holder (GH-21401) #21402
  • [3.8] bpo-41247: asyncio.set_running_loop() cache running loop holder (GH-21401) #21403
  • [3.8] bpo-41247: asyncio.set_running_loop() cache running loop holder #21406
  • 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 2020-07-08.19:30:41.924>
    created_at = <Date 2020-07-08.19:00:14.846>
    labels = []
    title = 'asyncio.set_running_loop() cache running loop holder'
    updated_at = <Date 2020-07-09.17:39:05.169>
    user = 'https://github.com/tontinton'

    bugs.python.org fields:

    activity = <Date 2020-07-09.17:39:05.169>
    actor = 'yselivanov'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-07-08.19:30:41.924>
    closer = 'yselivanov'
    components = []
    creation = <Date 2020-07-08.19:00:14.846>
    creator = 'tontinton'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 41247
    keywords = ['patch']
    message_count = 5.0
    messages = ['373333', '373336', '373337', '373340', '373409']
    nosy_count = 3.0
    nosy_names = ['yselivanov', 'miss-islington', 'tontinton']
    pr_nums = ['21401', '21402', '21403', '21406']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue41247'
    versions = []

    @tontinton
    Copy link
    Mannequin Author

    tontinton mannequin commented Jul 8, 2020

    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.

    @tontinton tontinton mannequin changed the title asyncio module better caching for set and get_running_loop asyncio.set_running_loop() cache running loop holder Jul 8, 2020
    @miss-islington
    Copy link
    Contributor

    New changeset 529f426 by Tony Solomonik in branch 'master':
    bpo-41247: asyncio.set_running_loop() cache running loop holder (GH-21401)
    529f426

    @1st1
    Copy link
    Member

    1st1 commented Jul 8, 2020

    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.

    @1st1 1st1 closed this as completed Jul 8, 2020
    @miss-islington
    Copy link
    Contributor

    New changeset fbd71f6 by Miss Islington (bot) in branch '3.9':
    bpo-41247: asyncio.set_running_loop() cache running loop holder (GH-21401)
    fbd71f6

    @1st1
    Copy link
    Member

    1st1 commented Jul 9, 2020

    New changeset 0b6169e by Tony Solomonik in branch '3.8':
    bpo-41247: asyncio.set_running_loop() cache running loop holder (bpo-21406)
    0b6169e

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    None yet
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants