From 3f78ca1cc9158ae4a1de20f27e71bca08bc16b16 Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Mon, 11 Oct 2021 16:30:48 -0400 Subject: [PATCH] Add explicit 3 second timeout to requests --- client-cli/pvc/cli_lib/common.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/client-cli/pvc/cli_lib/common.py b/client-cli/pvc/cli_lib/common.py index 955005d0..0e02b146 100644 --- a/client-cli/pvc/cli_lib/common.py +++ b/client-cli/pvc/cli_lib/common.py @@ -124,6 +124,9 @@ def call_api(config, operation, request_uri, headers={}, params=None, data=None, request_uri ) + # Default timeout is 3 seconds + timeout = 3 + # Craft the authentication header if required if config['api_key']: headers['X-Api-Key'] = config['api_key'] @@ -134,6 +137,7 @@ def call_api(config, operation, request_uri, headers={}, params=None, data=None, if operation == 'get': response = requests.get( uri, + timeout=timeout, headers=headers, params=params, data=data, @@ -142,6 +146,7 @@ def call_api(config, operation, request_uri, headers={}, params=None, data=None, if operation == 'post': response = requests.post( uri, + timeout=timeout, headers=headers, params=params, data=data, @@ -151,6 +156,7 @@ def call_api(config, operation, request_uri, headers={}, params=None, data=None, if operation == 'put': response = requests.put( uri, + timeout=timeout, headers=headers, params=params, data=data, @@ -160,6 +166,7 @@ def call_api(config, operation, request_uri, headers={}, params=None, data=None, if operation == 'patch': response = requests.patch( uri, + timeout=timeout, headers=headers, params=params, data=data, @@ -168,6 +175,7 @@ def call_api(config, operation, request_uri, headers={}, params=None, data=None, if operation == 'delete': response = requests.delete( uri, + timeout=timeout, headers=headers, params=params, data=data,