From a71ad237f1114cecf2a1a3bdff2c0e825d7bb5cb Mon Sep 17 00:00:00 2001 From: Michael Gummelt Date: Mon, 29 Jun 2015 15:10:03 -0700 Subject: [PATCH] hopefully this fixes CLI commands hanging --- cli/dcoscli/analytics.py | 4 +++- cli/tests/integrations/test_analytics.py | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/cli/dcoscli/analytics.py b/cli/dcoscli/analytics.py index edbbea5..d9f5eb7 100644 --- a/cli/dcoscli/analytics.py +++ b/cli/dcoscli/analytics.py @@ -103,10 +103,12 @@ def _segment_request(path, data): SEGMENT_IO_WRITE_KEY_DEV try: + # Set both the connect timeout and the request timeout to 1s, + # to prevent rollbar from hanging the CLI commands http.post('{}/{}'.format(SEGMENT_URL, path), json=data, auth=HTTPBasicAuth(key, ''), - timeout=1) + timeout=(1, 1)) except Exception as e: logger.exception(e) diff --git a/cli/tests/integrations/test_analytics.py b/cli/tests/integrations/test_analytics.py index 769e7af..e5f086a 100644 --- a/cli/tests/integrations/test_analytics.py +++ b/cli/tests/integrations/test_analytics.py @@ -89,7 +89,7 @@ def test_config_set(): assert mock_called_some_args(http.post, '{}/identify'.format(SEGMENT_URL), json={'userId': 'test@mail.com'}, - timeout=1) + timeout=(1, 1)) @_mock @@ -112,7 +112,7 @@ def test_no_exc(): assert mock_called_some_args(http.post, '{}/track'.format(SEGMENT_URL), json=data, - timeout=1) + timeout=(1, 1)) # rollbar assert rollbar.report_message.call_count == 0 @@ -145,7 +145,7 @@ def test_exc(): assert mock_called_some_args(http.post, '{}/track'.format(SEGMENT_URL), json=data, - timeout=1) + timeout=(1, 1)) # rollbar props = _base_properties()