Skip to content

Commit cc720a6

Browse files
add default 1s timemouts
1 parent ba4213b commit cc720a6

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

kmsauth/__init__.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ def __init__(
5757
endpoint_url=None,
5858
token_cache_size=4096,
5959
stats=None,
60-
max_pool_connections=100
60+
max_pool_connections=100,
61+
connect_timeout=1,
62+
read_timeout=1,
6163
):
6264
"""Create a KMSTokenValidator object.
6365
@@ -109,14 +111,18 @@ def __init__(
109111
aws_secret_access_key=self.aws_creds['SecretAccessKey'],
110112
aws_session_token=self.aws_creds['SessionToken'],
111113
endpoint_url=endpoint_url,
112-
max_pool_connections=max_pool_connections
114+
max_pool_connections=max_pool_connections,
115+
connect_timeout=connect_timeout,
116+
read_timeout=read_timeout,
113117
)
114118
else:
115119
self.kms_client = kmsauth.services.get_boto_client(
116120
'kms',
117121
region=self.region,
118122
endpoint_url=endpoint_url,
119-
max_pool_connections=max_pool_connections
123+
max_pool_connections=max_pool_connections,
124+
connect_timeout=connect_timeout,
125+
read_timeout=read_timeout,
120126
)
121127
if extra_context is None:
122128
self.extra_context = {}

kmsauth/services.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ def get_boto_client(
1515
aws_secret_access_key=None,
1616
aws_session_token=None,
1717
endpoint_url=None,
18-
max_pool_connections=None
18+
max_pool_connections=None,
19+
connect_timeout=None,
20+
read_timeout=None,
1921
):
2022
"""Get a boto3 client connection."""
2123
cache_key = '{0}:{1}:{2}:{3}'.format(
@@ -41,7 +43,9 @@ def get_boto_client(
4143
client,
4244
endpoint_url=endpoint_url,
4345
config=botocore.config.Config(
44-
max_pool_connections=max_pool_connections
46+
max_pool_connections=max_pool_connections,
47+
connect_timeout=connect_timeout,
48+
read_timeout=read_timeout,
4549
)
4650
)
4751
return CLIENT_CACHE[cache_key]

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
from setuptools import setup, find_packages
1515

16-
VERSION = "0.6.2.dev1"
16+
VERSION = "0.6.2.dev2"
1717

1818
requirements = [
1919
# Boto3 is the Amazon Web Services (AWS) Software Development Kit (SDK)

0 commit comments

Comments
 (0)