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 05:00:57 (GMT)
commit80fbacc9369c07daeea6a50a61d214820bb29874 (patch)
tree8304366bf5008f5005aa293e712673f4e419352d /Lib/asyncio
parent8b73b6198bc0753c5ce6e8f91eb7bddc2bd42a73 (diff)
downloadcpython-80fbacc9369c07daeea6a50a61d214820bb29874.zip
cpython-80fbacc9369c07daeea6a50a61d214820bb29874.tar.gz
cpython-80fbacc9369c07daeea6a50a61d214820bb29874.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):