fix: align AsyncNode retry mechanism with Node implementation

- Change AsyncNode._exec() to use self.cur_retry instead of local variable i
- Ensures consistency between sync and async retry mechanisms
- Fixes AttributeError when accessing cur_retry in derived classes
- Maintains backward compatibility while resolving retry tracking inconsistency
This commit is contained in:
spadkins 2025-07-31 12:11:14 +08:00
parent 3f1f1d6573
commit fd5817fdcc
1 changed files with 2 additions and 2 deletions

View File

@ -62,10 +62,10 @@ class AsyncNode(Node):
async def exec_fallback_async(self,prep_res,exc): raise exc
async def post_async(self,shared,prep_res,exec_res): pass
async def _exec(self,prep_res):
for i in range(self.max_retries):
for self.cur_retry in range(self.max_retries):
try: return await self.exec_async(prep_res)
except Exception as e:
if i==self.max_retries-1: return await self.exec_fallback_async(prep_res,e)
if self.cur_retry==self.max_retries-1: return await self.exec_fallback_async(prep_res,e)
if self.wait>0: await asyncio.sleep(self.wait)
async def run_async(self,shared):
if self.successors: warnings.warn("Node won't run successors. Use AsyncFlow.")