File tree 2 files changed +5
-6
lines changed
2 files changed +5
-6
lines changed Original file line number Diff line number Diff line change @@ -606,8 +606,7 @@ def new_event_loop(self):
606
606
607
607
# A TLS for the running event loop, used by _get_running_loop.
608
608
class _RunningLoop (threading .local ):
609
- _loop = None
610
- _pid = None
609
+ loop_pid = (None , None )
611
610
612
611
613
612
_running_loop = _RunningLoop ()
@@ -619,8 +618,8 @@ def _get_running_loop():
619
618
This is a low-level function intended to be used by event loops.
620
619
This function is thread-specific.
621
620
"""
622
- running_loop = _running_loop ._loop
623
- if running_loop is not None and _running_loop . _pid == os .getpid ():
621
+ running_loop , pid = _running_loop .loop_pid
622
+ if running_loop is not None and pid == os .getpid ():
624
623
return running_loop
625
624
626
625
@@ -630,8 +629,7 @@ def _set_running_loop(loop):
630
629
This is a low-level function intended to be used by event loops.
631
630
This function is thread-specific.
632
631
"""
633
- _running_loop ._pid = os .getpid ()
634
- _running_loop ._loop = loop
632
+ _running_loop .loop_pid = (loop , os .getpid ())
635
633
636
634
637
635
def _init_event_loop_policy ():
Original file line number Diff line number Diff line change
1
+ Micro-optimize :func: `asyncio._get_running_loop ` to become up to 10% faster.
You can’t perform that action at this time.
0 commit comments