asyncio: Optimize _get_running_loop() to call getpid() only when there's a loop

This commit is contained in:
Yury Selivanov 2017-03-02 23:57:33 -05:00
parent 84af903f3b
commit 902e9c50e3

View file

@ -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):