mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-08-03 06:17:29 +08:00
fix(common/misc_utils): allow once decorator retries after failure (#16174)
### What problem does this PR solve? `common/misc_utils.once` set `executed=True` before invoking the wrapped function, so an exception on the first call permanently disabled future calls and returned the cached `None`. This change marks `executed=True` only after a successful call, allowing retries after transient failures while preserving once-only behavior after success. It also adds regression tests for retry-after-exception and thread-safe single execution. ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --------- Co-authored-by: Harsh Kashyap <harshkashyap@Harshs-MacBook-Pro.local> Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: Jin Hai <haijin.chn@gmail.com>
This commit is contained in:
@@ -224,8 +224,8 @@ def once(func):
|
||||
nonlocal executed, result
|
||||
with lock:
|
||||
if not executed:
|
||||
executed = True
|
||||
result = func(*args, **kwargs)
|
||||
executed = True
|
||||
return result
|
||||
|
||||
return wrapper
|
||||
|
||||
Reference in New Issue
Block a user