From c0ea15226d5de8cd5025cc3db60e226da1251218 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Sat, 5 Dec 2020 18:08:16 +0200 Subject: [PATCH 1/2] rehash: try to sleep in 0.1 sec steps when acquiring lock --- libexec/pyenv-rehash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libexec/pyenv-rehash b/libexec/pyenv-rehash index 5c421c41..33b7e233 100755 --- a/libexec/pyenv-rehash +++ b/libexec/pyenv-rehash @@ -45,8 +45,8 @@ for (( i=1; i<="${PYENV_REHASH_TIMEOUT:-60}"; i++ )); do acquired=1 break else - # POSIX sleep(1) doesn't provides time precision of subsecond - sleep 1 + # POSIX sleep(1) doesn't provide subsecond precision, but many others do + sleep 0.1 2>/dev/null || sleep 1 fi done From b938abdea1480496fa5b402783539b16bbfb86d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Sat, 9 Jan 2021 10:21:11 +0200 Subject: [PATCH 2/2] rehash: preserve existing $PYENV_REHASH_TIMEOUT semantics Try for that long no matter what the sleep step available is. --- libexec/pyenv-rehash | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libexec/pyenv-rehash b/libexec/pyenv-rehash index 33b7e233..4e31994e 100755 --- a/libexec/pyenv-rehash +++ b/libexec/pyenv-rehash @@ -40,7 +40,8 @@ if [ ! -w "$SHIM_PATH" ]; then fi unset acquired -for (( i=1; i<="${PYENV_REHASH_TIMEOUT:-60}"; i++ )); do +start=$SECONDS +while (( SECONDS <= start + ${PYENV_REHASH_TIMEOUT:-60} )); do if acquire_lock 2>/dev/null; then acquired=1 break