Skip to content

Commit e952b37

Browse files
fabianbuechlerFabian Büchler
authored andcommitted
Reduce timeout in _wait_for_server_start to 25s
Modify Retry.total in Pact._wait_for_server_start to reduce the total wait time from 54 minutes to about 25 seconds. With a Retry.backoff_factor of 0.1 and 15 retries, the total wait time before an error is `sum([0.1 * (2**(i - 1)) for i in range(16)])` which is 3276 seconds or 54 minutes.
1 parent fde4fa2 commit e952b37

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

pact/pact.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ def _wait_for_server_start(self):
256256
:raises RuntimeError: If there is a problem starting the mock service.
257257
"""
258258
s = requests.Session()
259-
retries = Retry(total=15, backoff_factor=0.1)
259+
retries = Retry(total=9, backoff_factor=0.1)
260260
s.mount('http://', HTTPAdapter(max_retries=retries))
261261
resp = s.get(self.uri, headers=self.HEADERS)
262262
if resp.status_code != 200:

pact/test/test_pact.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ def test_wait_for_server_start_success(self):
334334
'http://localhost:1234', headers={'X-Pact-Mock-Service': 'true'})
335335
self.mock_HTTPAdapter.assert_called_once_with(
336336
max_retries=self.mock_Retry.return_value)
337-
self.mock_Retry.assert_called_once_with(total=15, backoff_factor=0.1)
337+
self.mock_Retry.assert_called_once_with(total=9, backoff_factor=0.1)
338338
self.assertFalse(pact._process.communicate.called)
339339
self.assertFalse(pact._process.terminate.called)
340340

@@ -352,7 +352,7 @@ def test_wait_for_server_start_failure(self):
352352
'http://localhost:1234', headers={'X-Pact-Mock-Service': 'true'})
353353
self.mock_HTTPAdapter.assert_called_once_with(
354354
max_retries=self.mock_Retry.return_value)
355-
self.mock_Retry.assert_called_once_with(total=15, backoff_factor=0.1)
355+
self.mock_Retry.assert_called_once_with(total=9, backoff_factor=0.1)
356356
pact._process.communicate.assert_called_once_with()
357357
pact._process.terminate.assert_called_once_with()
358358

0 commit comments

Comments
 (0)