MCPcopy Create free account
hub / github.com/Agent-RL/ReCall / decorator

Function decorator

scripts/evaluation/utils.py:29–41  ·  view source on GitHub ↗
(func)

Source from the content-addressed store, hash-verified

27
28def retry(max: int=10, sleep: int=1, logger: logging.Logger=None):
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
44def init_logger(log_path: str, log_name: str):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected