Update optimizer.py

This commit is contained in:
didi 2024-10-21 23:26:26 +08:00
parent d8c7174fc0
commit 35acb98d7a

View file

@ -82,26 +82,23 @@ class Optimizer:
retry_count = 0
max_retries = 1
score = loop.run_until_complete(self._optimize_graph())
while retry_count < max_retries:
try:
score = loop.run_until_complete(self._optimize_graph())
break
except Exception as e:
retry_count += 1
logger.info(f"Error occurred: {e}. Retrying... (Attempt {retry_count}/{max_retries})")
if retry_count == max_retries:
logger.info("Max retries reached. Moving to next round.")
score = None
# while retry_count < max_retries:
# try:
# score = loop.run_until_complete(self._optimize_graph())
# break
# except Exception as e:
# retry_count += 1
# logger.info(f"Error occurred: {e}. Retrying... (Attempt {retry_count}/{max_retries})")
# if retry_count == max_retries:
# logger.info("Max retries reached. Moving to next round.")
# score = None
wait_time = 5 * retry_count
time.sleep(wait_time)
# wait_time = 5 * retry_count
# time.sleep(wait_time)
# if retry_count < max_retries:
# loop = asyncio.new_event_loop()
# asyncio.set_event_loop(loop)
if retry_count < max_retries:
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
self.round += 1
logger.info(f"Score for round {self.round}: {score}")