summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio
diff options
context:
space:
mode:
authorYury Selivanov <yury@magic.io>2017-03-03 04:57:33 (GMT)
committerYury Selivanov <yury@magic.io>2017-03-03 04:58:07 (GMT)
commit902e9c50e31209e796b6bbe26f8d2f57ec12071b (patch)
tree87748c596b63944987b1089c9e3a7bb031e22d65 /Lib/asyncio
parent84af903f3bc6780cb4e73ff05ad2e242d3966417 (diff)
downloadcpython-902e9c50e31209e796b6bbe26f8d2f57ec12071b.zip
cpython-902e9c50e31209e796b6bbe26f8d2f57ec12071b.tar.gz
cpython-902e9c50e31209e796b6bbe26f8d2f57ec12071b.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.py5
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):