Skip to content

Commit

Permalink
feat: timeout config for network requests (#2683)
Browse files Browse the repository at this point in the history
Fixes #2680

Signed-off-by: Frost Ming <[email protected]>
  • Loading branch information
frostming authored Mar 13, 2024
1 parent aff56ce commit f251940
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions news/2680.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add configuration for timeout for network requests.
1 change: 1 addition & 0 deletions src/pdm/environments/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ def _build_session(self, trusted_hosts: list[str]) -> PDMSession:
cache_dir=self.project.cache("http"),
trusted_hosts=trusted_hosts,
ca_certificates=Path(ca_certs) if ca_certs is not None else None,
timeout=self.project.config["request_timeout"],
)
certfn = self.project.config.get("pypi.client_cert")
if certfn:
Expand Down
3 changes: 3 additions & 0 deletions src/pdm/project/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ class Config(MutableMapping[str, str]):
"PDM_BUILD_ISOLATION",
ensure_boolean,
),
"request_timeout": ConfigItem(
"The timeout for network requests in seconds", 15, True, "PDM_REQUEST_TIMEOUT", coerce=int
),
"global_project.fallback": ConfigItem(
"Use the global project implicitly if no local project is found",
False,
Expand Down

0 comments on commit f251940

Please sign in to comment.