Skip to content

Add asyncio.get_running_loop() function #76450

Closed

Description

@1st1
BPO 32269
Nosy @asvetlov, @1st1
PRs
  • bpo-32269: Add asyncio.get_running_loop(). #4782
  • 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 = 'https://github.com/1st1'
    closed_at = <Date 2017-12-11.15:08:02.879>
    created_at = <Date 2017-12-10.17:08:44.727>
    labels = ['type-feature', '3.7', 'expert-asyncio']
    title = 'Add `asyncio.get_running_loop()` function'
    updated_at = <Date 2017-12-11.15:08:52.294>
    user = 'https://github.com/1st1'

    bugs.python.org fields:

    activity = <Date 2017-12-11.15:08:52.294>
    actor = 'yselivanov'
    assignee = 'yselivanov'
    closed = True
    closed_date = <Date 2017-12-11.15:08:02.879>
    closer = 'yselivanov'
    components = ['asyncio']
    creation = <Date 2017-12-10.17:08:44.727>
    creator = 'yselivanov'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 32269
    keywords = ['patch']
    message_count = 2.0
    messages = ['307961', '308051']
    nosy_count = 2.0
    nosy_names = ['asvetlov', 'yselivanov']
    pr_nums = ['4782']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue32269'
    versions = ['Python 3.7']

    Activity

    1. 1st1 commented on Dec 10, 2017

      @1st1
      MemberAuthor

      In many contexts asyncio._get_running_loop() is more useful than asyncio.get_event_loop(). The former function is predictable and simple, the latter can change its behaviour depending on the current policy and can even create new event loops.

      Both asyncio._get_running_loop() and asyncio._set_running_loop() are public asyncio API, although the leading underscore suggests that they are special and shouldn't be used by regular users. That's true for asyncio._set_running_loop(), which is intended to be used by event loops exclusively.

      I propose to remove the leading underscore from asyncio._get_running_loop(), making it asyncio.get_running_loop(), and thus promoting a safer alternative to asyncio.get_event_loop().

      asyncio._get_running_loop() will be deprecated and removed in Python 3.9.

    2. self-assigned this
      on Dec 10, 2017
    3. added
      3.7 (EOL)
      type-feature
      on Dec 10, 2017
    4. 1st1 commented on Dec 11, 2017

      @1st1
      MemberAuthor

      asyncio._get_running_loop() will be deprecated and removed in Python 3.9.

      _get_running_loop() was left as-is.

    5. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    Labels

    3.7 (EOL)topic-asynciotype-feature

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions