From 48de78f9ae1dcf82bf0b248c25c911ef885400d2 Mon Sep 17 00:00:00 2001 From: Mohammed Jasil Date: Wed, 2 Apr 2025 12:02:55 +0530 Subject: [PATCH] Fix TypeError in exponential_delay function when handling connection timeouts Problem: - Agent v1.8.3-1~noble crashes on Ubuntu 24.04 with TypeError when receiver.amplify.nginx.com times out - Error occurs in backoff.py: "TypeError: 'float' object cannot be interpreted as an integer" - The issue prevents proper exponential backoff during network connectivity problems - Agent completely stops instead of retrying with the backoff delay Solution: - Add explicit integer type conversion to period_size before passing to randint() - Convert: return randint(0, period_size - 1) - To: return randint(0, int(period_size) - 1) This fix allows the agent to properly handle connection timeouts without crashing. The issue appears to be specific to Python 3.12 used in Ubuntu 24.04 Noble, as the agent works correctly on Ubuntu 22.04 Jammy with Python 3.10. Fixes #124 --- amplify/agent/common/util/backoff.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/amplify/agent/common/util/backoff.py b/amplify/agent/common/util/backoff.py index 0e95fc8..6e7d011 100644 --- a/amplify/agent/common/util/backoff.py +++ b/amplify/agent/common/util/backoff.py @@ -32,4 +32,4 @@ def exponential_delay(n): (EXPONENTIAL_COEFFICIENT ** n) period_size = min(exponential_limit, MAXIMUM_TIMEOUT) - return randint(0, period_size - 1) + return randint(0, int(period_size) - 1)