retry-logic

How do you obtain underlying failed request data when catching requests.exceptions.RetryError?

How do you obtain underlying failed request data when catching requests.exceptions.RetryError? Question: I am using a somewhat standard pattern for putting retry behavior around requests requests in Python, import requests from requests.adapters import HTTPAdapter from requests.packages.urllib3.util.retry import Retry retry_strategy = Retry( total=HTTP_RETRY_LIMIT, status_forcelist=HTTP_RETRY_CODES, method_whitelist=HTTP_RETRY_METHODS, backoff_factor=HTTP_BACKOFF_FACTOR ) adapter = HTTPAdapter(max_retries=retry_strategy) http = requests.Session() http.mount("https://", adapter) http.mount("http://", …

Total answers: 3

How to test Retry attempts in python using the request library

How to test Retry attempts in python using the request library Question: I have the following: from requests.adapters import HTTPAdapter from requests.packages.urllib3.util.retry import Retry retry_strategy = Retry( total=3, status_forcelist=[429, 500, 502, 503, 504], method_whitelist=["HEAD", "GET", "OPTIONS"] ) adapter = HTTPAdapter(max_retries=retry_strategy) http = requests.Session() http.mount("https://", adapter) http.mount("http://", adapter) response = http.get("some_endpoint") How can unit testing that …

Total answers: 1

Retry failed sqlalchemy queries

Retry failed sqlalchemy queries Question: Every time I’m restarting mysql service, my app is receiving the following error on any query: result = self._query(query) File “/usr/local/lib/python3.6/site-packages/pymysql/cursors.py”, line 328, in _query conn.query(q) File “/usr/local/lib/python3.6/site-packages/pymysql/connections.py”, line 516, in query self._affected_rows = self._read_query_result(unbuffered=unbuffered) File “/usr/local/lib/python3.6/site-packages/pymysql/connections.py”, line 727, in _read_query_result result.read() File “/usr/local/lib/python3.6/site-packages/pymysql/connections.py”, line 1066, in read first_packet = …

Total answers: 4