Increase retry attempts and adjust sleep duration for translation requests
Browse files- controllers/utils.py +3 -3
controllers/utils.py
CHANGED
@@ -161,12 +161,12 @@ def translate(text):
|
|
161 |
Returns:
|
162 |
str: The translated text in English.
|
163 |
"""
|
164 |
-
for i in range(
|
165 |
try:
|
166 |
return GoogleTranslator(source='auto', target='en').translate(text)
|
167 |
except exceptions.RequestError:
|
168 |
-
time.sleep(
|
169 |
-
return GoogleTranslator(source='auto', target='en').translate(text)
|
170 |
return ""
|
171 |
|
172 |
|
|
|
161 |
Returns:
|
162 |
str: The translated text in English.
|
163 |
"""
|
164 |
+
for i in range(5):
|
165 |
try:
|
166 |
return GoogleTranslator(source='auto', target='en').translate(text)
|
167 |
except exceptions.RequestError:
|
168 |
+
time.sleep(1)
|
169 |
+
# return GoogleTranslator(source='auto', target='en').translate(text)
|
170 |
return ""
|
171 |
|
172 |
|