classification
Title: Add `asyncio.get_running_loop()` function
Type: enhancement Stage: resolved
Components: asyncio Versions: Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: yselivanov Nosy List: asvetlov, yselivanov
Priority: normal Keywords: patch

Created on 2017-12-10 17:08 by yselivanov, last changed 2017-12-11 15:08 by yselivanov. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 4782 merged yselivanov, 2017-12-10 17:32
Messages (2)
msg307961 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2017-12-10 17:08
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.
msg308051 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2017-12-11 15:08
> `asyncio._get_running_loop()` will be deprecated and removed in Python 3.9.

_get_running_loop() was left as-is.
History
Date User Action Args
2017-12-11 15:08:52yselivanovsetmessages: + msg308051
2017-12-11 15:08:02yselivanovsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2017-12-10 17:32:05yselivanovsetkeywords: + patch
stage: patch review
pull_requests: + pull_request4683
2017-12-10 17:08:56yselivanovsettype: enhancement
components: + asyncio
versions: + Python 3.7
2017-12-10 17:08:44yselivanovcreate