File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change 66from urllib .parse import urlparse
77from django .http import QueryDict
88from django .conf import settings
9+ from urllib3 .util import Retry
10+ from requests .adapters import HTTPAdapter
911
1012LOCAL_ASTRO_HTTP = "http://custom-admin:3002"
1113
@@ -41,7 +43,17 @@ def astro_proxy(request, path):
4143 requests_args ["headers" ] = headers
4244 requests_args ["params" ] = params
4345
44- response = requests .request (request .method , url , ** requests_args )
46+ session = requests .Session ()
47+ retry = Retry (
48+ total = 5 ,
49+ backoff_factor = 0.1 ,
50+ status_forcelist = (500 , 502 , 504 ),
51+ )
52+ adapter = HTTPAdapter (max_retries = retry )
53+ session .mount ("http://" , adapter )
54+ session .mount ("https://" , adapter )
55+
56+ response = session .request (request .method , url , ** requests_args )
4557 content = response .content .decode ("utf-8" )
4658
4759 # Base path doesn't seem to be fully supported by Astro
You can’t perform that action at this time.
0 commit comments