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

Method WaitLoop

synthetic-multi-round-qa/utils.py:57–77  ·  view source on GitHub ↗
(cls)

Source from the content-addressed store, hash-verified

55
56 @classmethod
57 def WaitLoop(cls):
58 assert cls._loop is not None, "Loop is not started"
59
60 async def wait_for_tasks():
61 current_task = asyncio.current_task(cls._loop)
62 tasks = [
63 task
64 for task in asyncio.all_tasks(cls._loop)
65 if not task.done() and task is not current_task
66 ]
67 cls._logger.info(f"Waiting for {len(tasks)} tasks to finish")
68 if tasks:
69 await asyncio.gather(*tasks)
70
71 # Schedule the wait_for_tasks coroutine to be executed in the loop
72 future = asyncio.run_coroutine_threadsafe(wait_for_tasks(), cls._loop)
73 try:
74 # Wait for wait_for_tasks to complete
75 future.result()
76 except Exception as e:
77 cls._logger.error(f"Error while waiting for tasks: {e}")
78
79 @classmethod
80 def StartLoop(cls):

Callers 2

warmup_engineFunction · 0.45
StopLoopMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected