Fix httpx.Timeout configuration in PyPI proxy
This commit is contained in:
@@ -156,10 +156,7 @@ async def pypi_simple_index(
|
|||||||
|
|
||||||
simple_url = source.url.rstrip('/') + '/simple/'
|
simple_url = source.url.rstrip('/') + '/simple/'
|
||||||
|
|
||||||
timeout = httpx.Timeout(
|
timeout = httpx.Timeout(PROXY_READ_TIMEOUT, connect=PROXY_CONNECT_TIMEOUT)
|
||||||
connect=PROXY_CONNECT_TIMEOUT,
|
|
||||||
read=PROXY_READ_TIMEOUT,
|
|
||||||
)
|
|
||||||
|
|
||||||
with httpx.Client(timeout=timeout, follow_redirects=False) as client:
|
with httpx.Client(timeout=timeout, follow_redirects=False) as client:
|
||||||
response = client.get(
|
response = client.get(
|
||||||
@@ -247,10 +244,7 @@ async def pypi_package_versions(
|
|||||||
|
|
||||||
package_url = source.url.rstrip('/') + f'/simple/{normalized_name}/'
|
package_url = source.url.rstrip('/') + f'/simple/{normalized_name}/'
|
||||||
|
|
||||||
timeout = httpx.Timeout(
|
timeout = httpx.Timeout(PROXY_READ_TIMEOUT, connect=PROXY_CONNECT_TIMEOUT)
|
||||||
connect=PROXY_CONNECT_TIMEOUT,
|
|
||||||
read=PROXY_READ_TIMEOUT,
|
|
||||||
)
|
|
||||||
|
|
||||||
with httpx.Client(timeout=timeout, follow_redirects=False) as client:
|
with httpx.Client(timeout=timeout, follow_redirects=False) as client:
|
||||||
response = client.get(
|
response = client.get(
|
||||||
@@ -385,10 +379,7 @@ async def pypi_download_file(
|
|||||||
headers.update(_build_auth_headers(matched_source))
|
headers.update(_build_auth_headers(matched_source))
|
||||||
auth = _get_basic_auth(matched_source) if matched_source else None
|
auth = _get_basic_auth(matched_source) if matched_source else None
|
||||||
|
|
||||||
timeout = httpx.Timeout(
|
timeout = httpx.Timeout(300.0, connect=PROXY_CONNECT_TIMEOUT) # 5 minutes for large files
|
||||||
connect=PROXY_CONNECT_TIMEOUT,
|
|
||||||
read=300.0, # 5 minutes for large files
|
|
||||||
)
|
|
||||||
|
|
||||||
# Fetch the file
|
# Fetch the file
|
||||||
logger.info(f"PyPI proxy: fetching {filename} from {upstream_url}")
|
logger.info(f"PyPI proxy: fetching {filename} from {upstream_url}")
|
||||||
|
|||||||
Reference in New Issue
Block a user