Yicong-Huang commented on code in PR #5667:
URL: https://github.com/apache/texera/pull/5667#discussion_r3418836085
##########
amber/src/main/python/pytexera/storage/dataset_file_document.py:
##########
@@ -19,6 +19,34 @@
import os
import requests
import urllib.parse
+from requests.adapters import HTTPAdapter
+from urllib3.util.retry import Retry
+
+# (connect, read) timeout and retry settings for the file-service GETs below.
+_CONNECT_TIMEOUT_SECONDS = 10
+_READ_TIMEOUT_SECONDS = 60
+_REQUEST_TIMEOUT = (_CONNECT_TIMEOUT_SECONDS, _READ_TIMEOUT_SECONDS)
+_MAX_RETRIES = 3
+_RETRY_BACKOFF_FACTOR = 0.5
+_RETRY_STATUS_FORCELIST = (500, 502, 503, 504)
+
+
+def _build_session() -> requests.Session:
+ """Returns a Session that retries GETs on connection errors and 5xx."""
+ retry = Retry(
+ total=_MAX_RETRIES,
+ connect=_MAX_RETRIES,
+ read=_MAX_RETRIES,
+ backoff_factor=_RETRY_BACKOFF_FACTOR,
+ status_forcelist=_RETRY_STATUS_FORCELIST,
+ allowed_methods=frozenset({"GET"}),
+ raise_on_status=False,
+ )
+ adapter = HTTPAdapter(max_retries=retry)
+ session = requests.Session()
+ session.mount("http://", adapter)
+ session.mount("https://", adapter)
+ return session
Review Comment:
thanks!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]