MCPcopy Index your code
hub / github.com/1Panel-dev/MaxKB / wrapper

Function wrapper

apps/common/utils/lock.py:63–72  ·  view source on GitHub ↗
(*args, **kwargs)

Source from the content-addressed store, hash-verified

61 def decorator(func):
62 @wraps(func)
63 def wrapper(*args, **kwargs):
64 key = lock_key(*args, **kwargs) if callable(lock_key) else lock_key
65 rlock = RedisLock()
66 if not rlock.try_lock(key, timeout):
67 # 获取锁失败,可自定义异常或返回
68 return None
69 try:
70 return func(*args, **kwargs)
71 finally:
72 rlock.un_lock(key)
73
74 return wrapper
75

Callers

nothing calls this directly

Calls 3

try_lockMethod · 0.95
un_lockMethod · 0.95
RedisLockClass · 0.85

Tested by

no test coverage detected