diff options
author | Yury Selivanov <yury@magic.io> | 2017-03-03 04:57:33 (GMT) |
---|---|---|
committer | Yury Selivanov <yury@magic.io> | 2017-03-03 04:58:29 (GMT) |
commit | 2ef08d3be780457c444741b67e6181675b044be9 (patch) | |
tree | 9e3948c14fd212f416f897cd2ae045d7e337241a /Lib/asyncio | |
parent | 604faba1db724951ee440337099d111e3ecade49 (diff) | |
download | cpython-2ef08d3be780457c444741b67e6181675b044be9.zip cpython-2ef08d3be780457c444741b67e6181675b044be9.tar.gz cpython-2ef08d3be780457c444741b67e6181675b044be9.tar.bz2 |
asyncio: Optimize _get_running_loop() to call getpid() only when there's a loop
Diffstat (limited to 'Lib/asyncio')
-rw-r--r-- | Lib/asyncio/events.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Lib/asyncio/events.py b/Lib/asyncio/events.py index 7b30b4c..e85634e 100644 --- a/Lib/asyncio/events.py +++ b/Lib/asyncio/events.py @@ -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): |