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

Function final_decro

tools/_utils.py:235–249  ·  view source on GitHub ↗

Not using async.Semaphore to aovid use nest-asyncio

(func)

Source from the content-addressed store, hash-verified

233 """Add restriction of maximum async calling times for a async func"""
234
235 def final_decro(func):
236 """Not using async.Semaphore to aovid use nest-asyncio"""
237 __current_size = 0
238
239 @wraps(func)
240 async def wait_func(*args, **kwargs):
241 nonlocal __current_size
242 while __current_size >= max_size:
243 await asyncio.sleep(waitting_time)
244 __current_size += 1
245 result = await func(*args, **kwargs)
246 __current_size -= 1
247 return result
248
249 return wait_func
250
251 return final_decro
252

Callers

nothing calls this directly

Calls 1

EmbeddingFuncClass · 0.85

Tested by

no test coverage detected