Skip to content
This repository has been archived by the owner on Dec 1, 2018. It is now read-only.

Add timeout to pykube HTTPClient #156

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion pykube/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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))
Expand Down Expand Up @@ -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):
Expand Down