MCPcopy Create free account
hub / github.com/RUC-NLPIR/SmartSearch / wrapper

Function wrapper

scripts/evaluation/utils.py:31–40  ·  view source on GitHub ↗
(*args, **kwargs)

Source from the content-addressed store, hash-verified

29 def decorator(func):
30 @wraps(func)
31 def wrapper(*args, **kwargs):
32 for i in range(max):
33 try:
34 return func(*args, **kwargs)
35 except Exception as e:
36 logger.info(f"[retry] try {i} times")
37 if i == max - 1:
38 raise Exception("Error: {}. Retry {} failed after {} times".format(e, func.__name__, max))
39 elif sleep:
40 time.sleep(sleep)
41 return wrapper
42 return decorator
43

Callers

nothing calls this directly

Calls 1

funcFunction · 0.85

Tested by

no test coverage detected