diff options
author | Paul Ganssle <paul@ganssle.io> | 2016-01-13 10:46:07 -0500 |
---|---|---|
committer | Paul Ganssle <paul@ganssle.io> | 2016-02-15 16:04:06 -0500 |
commit | d77214b277559393217ca125317923d63870669d (patch) | |
tree | e1c2ba3e654d4419d23e116f11661bdd3965c57d | |
parent | d4baf97155f37c4ed2c5a87f444a3900aa9a37e7 (diff) | |
download | dateutil-d77214b277559393217ca125317923d63870669d.tar.gz |
Add retry logic for appveyor and travis to (at least partially) mitigate timeout errors.
-rw-r--r-- | .travis.yml | 2 | ||||
-rw-r--r-- | appveyor.yml | 6 | ||||
-rw-r--r-- | ci_tools/retry.bat | 18 | ||||
-rwxr-xr-x | ci_tools/retry.sh | 10 |
4 files changed, 33 insertions, 3 deletions
diff --git a/.travis.yml b/.travis.yml index 66e2b74..78c77db 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,7 @@ python: install: - pip install six - if [[ $TRAVIS_PYTHON_VERSION == '2.6' ]]; then pip install unittest2; fi - - python updatezinfo.py + - ./ci_tools/retry.sh python updatezinfo.py script: - python setup.py test sudo: false diff --git a/appveyor.yml b/appveyor.yml index 8458d25..3a0ffab 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -10,11 +10,13 @@ environment: - PYTHON: "C:/Python35" - PYTHON: "C:/Python35-x64" install: - - ps: Start-FileDownload 'https://raw.github.com/pypa/pip/master/contrib/get-pip.py' + - ps: Start-FileDownload 'https://bootstrap.pypa.io/get-pip.py' - "%PYTHON%/python.exe get-pip.py" - "%PYTHON%/Scripts/pip.exe install six" # use postgres' zic - set path=c:\Program Files\PostgreSQL\9.3\bin\;%PATH% - - "%PYTHON%/python.exe updatezinfo.py" + # This frequently fails with network errors, so we'll retry it up to 5 times + # with a 1 minute rate limit. + - "ci_tools/retry.bat %PYTHON%/python.exe updatezinfo.py" test_script: - "%PYTHON%/python.exe setup.py test" diff --git a/ci_tools/retry.bat b/ci_tools/retry.bat new file mode 100644 index 0000000..9ddc225 --- /dev/null +++ b/ci_tools/retry.bat @@ -0,0 +1,18 @@ +@echo off +REM This script takes a command and retries it a few times if it fails, with a +REM timeout between each retry. + +setlocal EnableDelayedExpansion + +REM Loop at most n_retries times, waiting sleep_time times between +set sleep_time=60 +set n_retries=5 + +for /l %%x in (1, 1, %n_retries%) do ( + call %* + if not ERRORLEVEL 1 EXIT /B 0 + timeout /t %sleep_time% /nobreak > nul +) + +REM If it failed all n_retries times, we can give up at last. +EXIT /B 1
\ No newline at end of file diff --git a/ci_tools/retry.sh b/ci_tools/retry.sh new file mode 100755 index 0000000..03b4ee2 --- /dev/null +++ b/ci_tools/retry.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +sleep_time=60 +n_retries=5 + +for i in `seq 1 $n_retries`; do + "$@" && exit 0 + sleep $sleep_time +done + +exit 1 |