Merge pull request #101 from hyh19/main

Fix AsyncNode retry mechanism to use self.cur_retry attribute
This commit is contained in:
Zachary Huang 2025-07-31 08:17:19 -07:00 committed by GitHub
commit 66d2fa09f9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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 exec_fallback_async(self,prep_res,exc): raise exc
async def post_async(self,shared,prep_res,exec_res): pass async def post_async(self,shared,prep_res,exec_res): pass
async def _exec(self,prep_res): 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) try: return await self.exec_async(prep_res)
except Exception as e: 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) if self.wait>0: await asyncio.sleep(self.wait)
async def run_async(self,shared): async def run_async(self,shared):
if self.successors: warnings.warn("Node won't run successors. Use AsyncFlow.") if self.successors: warnings.warn("Node won't run successors. Use AsyncFlow.")