mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-30 10:07:14 +02:00
Look for another mirror on any requests.exceptions.RequestException
This commit is contained in:
@ -13,7 +13,6 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import math
|
|
||||||
import os
|
import os
|
||||||
import socket
|
import socket
|
||||||
from urllib.parse import urljoin
|
from urllib.parse import urljoin
|
||||||
@ -63,9 +62,10 @@ class EndpointSessionIterator:
|
|||||||
endpoints = [endpoints]
|
endpoints = [endpoints]
|
||||||
self.endpoints = endpoints
|
self.endpoints = endpoints
|
||||||
self.endpoints_iter = iter(endpoints)
|
self.endpoints_iter = iter(endpoints)
|
||||||
|
# https://urllib3.readthedocs.io/en/stable/reference/urllib3.util.html
|
||||||
self.retry = Retry(
|
self.retry = Retry(
|
||||||
total=math.ceil(6 / len(self.endpoints)),
|
total=3,
|
||||||
backoff_factor=1,
|
backoff_factor=1, # [0, 2 4] secs
|
||||||
# method_whitelist=list(Retry.DEFAULT_METHOD_WHITELIST) + ["POST"],
|
# method_whitelist=list(Retry.DEFAULT_METHOD_WHITELIST) + ["POST"],
|
||||||
status_forcelist=[413, 429, 500, 502, 503, 504],
|
status_forcelist=[413, 429, 500, 502, 503, 504],
|
||||||
)
|
)
|
||||||
@ -129,10 +129,7 @@ class HTTPClient:
|
|||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
return getattr(self._session, method)(path, **kwargs)
|
return getattr(self._session, method)(path, **kwargs)
|
||||||
except (
|
except requests.exceptions.RequestException as exc:
|
||||||
requests.exceptions.ConnectionError,
|
|
||||||
requests.exceptions.Timeout,
|
|
||||||
) as exc:
|
|
||||||
try:
|
try:
|
||||||
self._next_session()
|
self._next_session()
|
||||||
except Exception as exc2:
|
except Exception as exc2:
|
||||||
|
Reference in New Issue
Block a user