MCPcopy Create free account
hub / github.com/KnowledgeXLab/LeanRAG / always_get_an_event_loop

Function always_get_an_event_loop

tools/_utils.py:19–28  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

17ENCODER = None
18
19def always_get_an_event_loop() -> asyncio.AbstractEventLoop:
20 try:
21 # If there is already an event loop, use it.
22 loop = asyncio.get_event_loop()
23 except RuntimeError:
24 # If in a sub-thread, create a new event loop.
25 logger.info("Creating a new event loop in a sub-thread.")
26 loop = asyncio.new_event_loop()
27 asyncio.set_event_loop(loop)
28 return loop
29
30
31def extract_first_complete_json(s: str):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected