mirror of
https://github.com/python/cpython.git
synced 2025-10-01 12:52:18 +00:00
asyncio: Optimize _get_running_loop() to call getpid() only when there's a loop
This commit is contained in:
parent
604faba1db
commit
2ef08d3be7
1 changed files with 3 additions and 2 deletions
|
@ -624,8 +624,9 @@ def _get_running_loop():
|
|||
This is a low-level function intended to be used by event loops.
|
||||
This function is thread-specific.
|
||||
"""
|
||||
if _running_loop._pid == os.getpid():
|
||||
return _running_loop._loop
|
||||
running_loop = _running_loop._loop
|
||||
if running_loop is not None and _running_loop._pid == os.getpid():
|
||||
return running_loop
|
||||
|
||||
|
||||
def _set_running_loop(loop):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue