Retry twine uploads in a loop
Now that we have a mechanism to check whether twine uploaded successfully, we can also safely retry it when it doesn't. Try to upload to PyPI up to three times, waiting progressively longer between retries. Change-Id: Id16909501d8ed2387daae71f75cf80de28297baf
This commit is contained in:
parent
16b12ba5b9
commit
9ee3e76a66
@ -34,6 +34,21 @@ curl --fail -o $FILENAME http://$TARBALL_SITE/$PROJECT/$FILENAME
|
|||||||
file -b $FILENAME | grep gzip
|
file -b $FILENAME | grep gzip
|
||||||
|
|
||||||
# Uploads may claim to fail but actually succeed so we check if we
|
# Uploads may claim to fail but actually succeed so we check if we
|
||||||
# can download after upload to determine success.
|
# can download after upload to determine success. They can also fail
|
||||||
twine upload -r pypi $FILENAME || true
|
# intermittently, so retrying in a delayed loop helps improve
|
||||||
curl --head --silent --fail "https://pypi.python.org/simple/$PROJECT/$FILENAME" >/dev/null 2>&1
|
# robustness.
|
||||||
|
TRY=0
|
||||||
|
RETVAL=255
|
||||||
|
set +e
|
||||||
|
while [[ $TRY -lt 3 ]] && [[ $RETVAL -ne 0 ]]; do
|
||||||
|
twine upload -r pypi $FILENAME
|
||||||
|
curl --head --silent --fail \
|
||||||
|
"https://pypi.python.org/simple/$PROJECT/$FILENAME" >/dev/null 2>&1
|
||||||
|
RETVAL=$?
|
||||||
|
(( TRY++ ))
|
||||||
|
if [[ $TRY -lt 3 ]] && [[ $RETVAL -ne 0 ]]; then
|
||||||
|
echo "Upload failed, retrying in $TRY seconds." >&2
|
||||||
|
sleep $TRY
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
exit $RETVAL
|
||||||
|
@ -36,6 +36,21 @@ curl --fail -o $FILENAME http://$TARBALL_SITE/$PROJECT/$FILENAME
|
|||||||
file -b $FILENAME | grep -i zip
|
file -b $FILENAME | grep -i zip
|
||||||
|
|
||||||
# Uploads may claim to fail but actually succeed so we check if we
|
# Uploads may claim to fail but actually succeed so we check if we
|
||||||
# can download after upload to determine success.
|
# can download after upload to determine success. They can also fail
|
||||||
twine upload -r pypi $FILENAME || true
|
# intermittently, so retrying in a delayed loop helps improve
|
||||||
curl --head --silent --fail "https://pypi.python.org/simple/$PROJECT/$FILENAME" >/dev/null 2>&1
|
# robustness.
|
||||||
|
TRY=0
|
||||||
|
RETVAL=255
|
||||||
|
set +e
|
||||||
|
while [[ $TRY -lt 3 ]] && [[ $RETVAL -ne 0 ]]; do
|
||||||
|
twine upload -r pypi $FILENAME
|
||||||
|
curl --head --silent --fail \
|
||||||
|
"https://pypi.python.org/simple/$PROJECT/$FILENAME" >/dev/null 2>&1
|
||||||
|
RETVAL=$?
|
||||||
|
(( TRY++ ))
|
||||||
|
if [[ $TRY -lt 3 ]] && [[ $RETVAL -ne 0 ]]; then
|
||||||
|
echo "Upload failed, retrying in $TRY seconds." >&2
|
||||||
|
sleep $TRY
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
exit $RETVAL
|
||||||
|
Loading…
Reference in New Issue
Block a user