Skip to content
This repository was archived by the owner on Mar 13, 2022. It is now read-only.

Commit ce61978

Browse files
authored
Merge branch 'master' into enable-oidc
2 parents 079c8fd + 84d1284 commit ce61978

File tree

3 files changed

+35
-5
lines changed

3 files changed

+35
-5
lines changed

configuration.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
from __future__ import absolute_import
2222

23+
import multiprocessing
2324
import logging
2425
import sys
2526

@@ -83,11 +84,12 @@ def __init__(self):
8384
# Set this to True/False to enable/disable SSL hostname verification.
8485
self.assert_hostname = None
8586
# urllib3 connection pool's maximum number of connections saved
86-
# per pool. Increasing this is useful for cases when you are
87-
# making a lot of possibly parallel requests to the same host,
88-
# which is often the case here.
89-
# When set to `None`, will default to whatever urllib3 uses
90-
self.connection_pool_maxsize = None
87+
# per pool. urllib3 uses 1 connection as default value, but this is
88+
# not the best value when you are making a lot of possibly parallel
89+
# requests to the same host, which is often the case here.
90+
# cpu_count * 5 is used as default value to increase performance
91+
# This is used because it's the default value for ThreadPoolExecutor
92+
self.connection_pool_maxsize = multiprocessing.cpu_count() * 5
9193
# http proxy setting
9294
self.http_proxy_url = None
9395

watch/watch.py

+1
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ def stream(self, func, *args, **kwargs):
109109
watch.stop()
110110
"""
111111

112+
self._stop = False
112113
return_type = self.get_return_type(func)
113114
kwargs['watch'] = True
114115
kwargs['_preload_content'] = False

watch/watch_test.py

+27
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,33 @@ def test_watch_with_decode(self):
5858
fake_resp.close.assert_called_once()
5959
fake_resp.release_conn.assert_called_once()
6060

61+
def test_watch_stream_twice(self):
62+
w = Watch(float)
63+
for step in ['first', 'second']:
64+
fake_resp = Mock()
65+
fake_resp.close = Mock()
66+
fake_resp.release_conn = Mock()
67+
fake_resp.read_chunked = Mock(
68+
return_value=['{"type": "ADDED", "object": 1}\n'] * 4)
69+
70+
fake_api = Mock()
71+
fake_api.get_namespaces = Mock(return_value=fake_resp)
72+
fake_api.get_namespaces.__doc__ = ':return: V1NamespaceList'
73+
74+
count = 1
75+
for e in w.stream(fake_api.get_namespaces):
76+
count += 1
77+
if count == 3:
78+
w.stop()
79+
80+
self.assertEqual(count, 3)
81+
fake_api.get_namespaces.assert_called_once_with(
82+
_preload_content=False, watch=True)
83+
fake_resp.read_chunked.assert_called_once_with(
84+
decode_content=False)
85+
fake_resp.close.assert_called_once()
86+
fake_resp.release_conn.assert_called_once()
87+
6188
def test_unmarshal_with_float_object(self):
6289
w = Watch()
6390
event = w.unmarshal_event('{"type": "ADDED", "object": 1}', 'float')

0 commit comments

Comments
 (0)