mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
asyncio: Optimize _get_running_loop() to call getpid() only when there's a loop
This commit is contained in:
parent
84af903f3b
commit
902e9c50e3
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