From c6cc160b9d884b9347ad5a64cfbbba22dfbc91ca Mon Sep 17 00:00:00 2001 From: tdstein Date: Mon, 10 Jul 2023 16:10:41 -0400 Subject: [PATCH] Sets the CONNECT_TASK_TIMEOUT default to 86,400. --- CHANGELOG.md | 2 +- rsconnect/timeouts.py | 5 ++--- tests/test_timeouts.py | 3 +-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f77791cf..58899f18 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -- The `CONNECT_TASK_TIMEOUT` environment variable, which configures the timeout for [task based operations](https://docs.posit.co/connect/api/#get-/v1/tasks/-id-). This value translates into seconds (e.g., `CONNECT_TASK_TIMEOUT=60` is equivalent to 60 seconds.) By default, this value is set to [`sys.maxsize`](https://docs.python.org/3/library/sys.html#sys.maxsize). +- The `CONNECT_TASK_TIMEOUT` environment variable, which configures the timeout for [task based operations](https://docs.posit.co/connect/api/#get-/v1/tasks/-id-). This value translates into seconds (e.g., `CONNECT_TASK_TIMEOUT=60` is equivalent to 60 seconds.) By default, this value is set to 86,400 seconds (e.g., 24 hours). ## [1.18.0] - 2023-06-27 diff --git a/rsconnect/timeouts.py b/rsconnect/timeouts.py index 326bb7c9..77ff1146 100644 --- a/rsconnect/timeouts.py +++ b/rsconnect/timeouts.py @@ -1,5 +1,4 @@ import os -import sys from typing import Union from rsconnect.exception import RSConnectException @@ -8,7 +7,7 @@ _CONNECT_REQUEST_TIMEOUT_DEFAULT_VALUE: str = "300" _CONNECT_TASK_TIMEOUT_KEY: str = "CONNECT_TASK_TIMEOUT" -_CONNECT_TASK_TIMEOUT_DEFAULT_VALUE: str = str(sys.maxsize) +_CONNECT_TASK_TIMEOUT_DEFAULT_VALUE: str = "86400" def get_request_timeout() -> int: @@ -50,7 +49,7 @@ def get_task_timeout() -> int: The timeout value is intended to be interpreted in seconds. A value of 60 is equal to sixty seconds, or one minute. - If CONNECT_TASK_TIMEOUT is unset, a default value of sys.maxsize is used. + If CONNECT_TASK_TIMEOUT is unset, a default value of 86,400 (1 day) is used. If CONNECT_TASK_TIMEOUT is set to a value less or equal to 0, an `RSConnectException` is raised. diff --git a/tests/test_timeouts.py b/tests/test_timeouts.py index 59951839..2698da09 100644 --- a/tests/test_timeouts.py +++ b/tests/test_timeouts.py @@ -1,5 +1,4 @@ import os -import sys from unittest import TestCase from unittest.mock import patch @@ -36,7 +35,7 @@ def test_get_negative_timeout_from_environment(self): class GetTaskTimeoutTestCase(TestCase): def test_get_default_timeout(self): timeout = get_task_timeout() - self.assertEqual(sys.maxsize, timeout) + self.assertEqual(24 * 60 * 60, timeout) def test_get_valid_timeout_from_environment(self): with patch.dict(os.environ, {"CONNECT_TASK_TIMEOUT": "24"}):