Skip to content
Permalink
Browse files

Try to make dependency downloading more robust to intermittent networ…

…k errors

PiperOrigin-RevId: 257086921
  • Loading branch information
petewarden authored and tensorflower-gardener committed Jul 9, 2019
1 parent 0384804 commit ad4b681bba821ac7fa59139b668bdd1f75b5eb1d
Showing with 17 additions and 1 deletion.
  1. +17 −1 tensorflow/lite/experimental/micro/tools/make/download_and_extract.sh
@@ -78,10 +78,26 @@ download_and_extract() {
local tempdir=$(mktemp -d)
local tempdir2=$(mktemp -d)
local tempfile=${tempdir}/temp_file
local curl_retries=3

echo "downloading ${url}" >&2
mkdir -p "${dir}"
curl -Ls --retry 5 "${url}" > ${tempfile}
# We've been seeing occasional 56 errors from valid URLs, so set up a retry
# loop to attempt to recover from them.
for (( i=1; i<=$curl_retries; ++i ))
do
CURL_RESULT=$(curl -Ls --retry 5 "${url}" > ${tempfile} || true)
if [[ $CURL_RESULT -eq 0 ]]
then
break
fi
if [[ ( $CURL_RESULT -ne 56 ) || ( $i -eq $curl_retries ) ]]
then
echo "Error $CURL_RESULT downloading '${url}'"
exit 1
fi
sleep 2
done

# Check that the file was downloaded correctly using a checksum.
DOWNLOADED_MD5=$(openssl dgst -md5 ${tempfile} | sed 's/.* //g')

0 comments on commit ad4b681

Please sign in to comment.
You can’t perform that action at this time.