Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
allendowney
GitHub Repository: allendowney/cpython
Path: blob/main/Lib/asyncio/mixins.py
12 views
1
"""Event loop mixins."""
2
3
import threading
4
from . import events
5
6
_global_lock = threading.Lock()
7
8
9
class _LoopBoundMixin:
10
_loop = None
11
12
def _get_loop(self):
13
loop = events._get_running_loop()
14
15
if self._loop is None:
16
with _global_lock:
17
if self._loop is None:
18
self._loop = loop
19
if loop is not self._loop:
20
raise RuntimeError(f'{self!r} is bound to a different event loop')
21
return loop
22
23