From 5de5e76f4f13b743a970c84ebd7a4546ac12009d Mon Sep 17 00:00:00 2001 From: Mohab Usama Date: Wed, 16 May 2018 17:11:41 +0200 Subject: [PATCH] Add timeout to pykube HTTPClient --- pykube/http.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pykube/http.py b/pykube/http.py index 8cdfdb6..40ebfcc 100644 --- a/pykube/http.py +++ b/pykube/http.py @@ -150,7 +150,7 @@ class HTTPClient(object): _session = None - def __init__(self, config): + def __init__(self, config, timeout=10): """ Creates a new instance of the HTTPClient. @@ -160,6 +160,8 @@ def __init__(self, config): self.config = config self.url = self.config.cluster["server"] + self.timeout = timeout + session = requests.Session() session.mount("https://", KubernetesHTTPAdapter(self.config)) session.mount("http://", KubernetesHTTPAdapter(self.config)) @@ -227,6 +229,7 @@ def get_kwargs(self, **kwargs): url = url[1:] bits.append(url) kwargs["url"] = self.url + posixpath.join(*bits) + kwargs["timeout"] = self.timeout return kwargs def raise_for_status(self, resp):