MCPcopy Create free account
hub / github.com/LMCache/LMCache / WaitLoop

Method WaitLoop

benchmarks/rag/utils.py:69–89  ·  view source on GitHub ↗
(cls)

Source from the content-addressed store, hash-verified

67
68 @classmethod
69 def WaitLoop(cls):
70 assert cls._loop is not None, "Loop is not started"
71
72 async def wait_for_tasks():
73 current_task = asyncio.current_task(cls._loop)
74 tasks = [
75 task
76 for task in asyncio.all_tasks(cls._loop)
77 if not task.done() and task is not current_task
78 ]
79 cls._logger.info(f"Waiting for {len(tasks)} tasks to finish")
80 if tasks:
81 await asyncio.gather(*tasks)
82
83 # Schedule the wait_for_tasks coroutine to be executed in the loop
84 future = asyncio.run_coroutine_threadsafe(wait_for_tasks(), cls._loop)
85 try:
86 # Wait for wait_for_tasks to complete
87 future.result()
88 except Exception as e:
89 cls._logger.error(f"Error while waiting for tasks: {e}")
90
91 @classmethod
92 def StartLoop(cls):

Callers 2

StopLoopMethod · 0.45
warmup_engineFunction · 0.45

Calls 1

resultMethod · 0.45

Tested by

no test coverage detected