Use separate connect and data timeouts

This allows us to keep a very low connect timeout of 3 seconds, but also
ensure that long commands (e.g. --wait or VM disable) can take as long
as the API requires to complete.

Avoids having to explicitly set very long single-instance timeouts for
other functions which would block forever on an unreachable API.
This commit is contained in:
2021-11-08 03:04:24 -05:00
parent 799c3e8d5d
commit e7d7378bae
2 changed files with 4 additions and 9 deletions

View File

@ -123,8 +123,10 @@ def call_api(
params=None,
data=None,
files=None,
timeout=3,
):
# Set the connect timeout to 3 seconds but extremely long (48 hour) data timeout
timeout = (3, 172800)
# Craft the URI
uri = "{}://{}{}{}".format(
config["api_scheme"], config["api_host"], config["api_prefix"], request_uri