Skip to content

Commit

Permalink
fix retry
Browse files Browse the repository at this point in the history
  • Loading branch information
pan-x-c committed Oct 8, 2024
1 parent 05d85af commit 60d0717
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/agentscope/rpc/retry_strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,14 @@ def retry( # pylint: disable=R1710
except Exception as e:
if attempt == self.max_retries:
raise TimeoutError("Max timeout exceeded.") from e
delay = (random.random() + 0.5) * delay
delay = min(delay, self.max_delay)
random_delay = min(
(random.random() + 0.5) * delay,
self.max_delay,
)
logger.info(
f"Attempt {attempt + 1} failed: {e}. Retrying in {delay} seconds...",
f"Attempt {attempt + 1} failed: {e}. Retrying in {random_delay} seconds...",
)
time.sleep(delay)
time.sleep(random_delay)
delay *= 2


Expand Down

0 comments on commit 60d0717

Please sign in to comment.