From: garciadeblas Date: Mon, 25 Nov 2024 09:53:37 +0000 (+0100) Subject: Add timeout to requests connections to prevent uncontrolled consumption of socket... X-Git-Tag: v17.0.0~12 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=19bc2f4c4a66d9b57c276f43510fa6e26d33e4f2;p=osm%2Fosmclient.git Add timeout to requests connections to prevent uncontrolled consumption of socket descriptors Change-Id: I273137f102371c246a80b491bc168542fe9e5029 Signed-off-by: garciadeblas --- diff --git a/osmclient/sol005/osmrepo.py b/osmclient/sol005/osmrepo.py index 48f69ef..69072a3 100644 --- a/osmclient/sol005/osmrepo.py +++ b/osmclient/sol005/osmrepo.py @@ -62,7 +62,7 @@ class OSMRepo(Repo): vnf_repos = [] for repository in repositories: try: - r = requests.get("{}/index.yaml".format(repository.get("url"))) + r = requests.get(f"{repository.get('url')}/index.yaml", timeout=10) if r.status_code == 200: repo_list = yaml.safe_load(r.text) @@ -133,6 +133,7 @@ class OSMRepo(Repo): r = requests.get( "{}{}".format(pkg.get("repourl"), pkg.get("location")), stream=True, + timeout=10, # Prevents uncontrolled consumption of socket descriptors ) if r.status_code != 200: raise ClientException("Package not found")