MCPcopy Create free account
hub / github.com/ZLMediaKit/pymkui / SharedLoop

Class SharedLoop

backend/shared_loop.py:13–34  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11
12
13class SharedLoop:
14 _loop = None
15 _thread = None
16
17 @classmethod
18 def get_loop(cls):
19 """全局唯一 asyncio loop"""
20 if cls._loop is None:
21 cls._loop = asyncio.new_event_loop()
22
23 def run(loop):
24 asyncio.set_event_loop(loop)
25 loop.run_forever()
26
27 cls._thread = threading.Thread(
28 target=run,
29 args=(cls._loop,),
30 daemon=True
31 )
32 cls._thread.start()
33
34 return cls._loop

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected