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 604faba1db
commit 2ef08d3be7

View file

@ -624,8 +624,9 @@ def _get_running_loop():
This is a low-level function intended to be used by event loops. This is a low-level function intended to be used by event loops.
This function is thread-specific. This function is thread-specific.
""" """
if _running_loop._pid == os.getpid(): running_loop = _running_loop._loop
return _running_loop._loop if running_loop is not None and _running_loop._pid == os.getpid():
return running_loop
def _set_running_loop(loop): def _set_running_loop(loop):