mirror of
https://github.com/pyenv/pyenv.git
synced 2024-11-21 20:47:00 -05:00
Merge pull request #1798 from scop/subsec-sleep
rehash: try to sleep in 0.1 sec steps when acquiring lock
This commit is contained in:
commit
b7efafe599
1 changed files with 4 additions and 3 deletions
|
@ -40,13 +40,14 @@ if [ ! -w "$SHIM_PATH" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
unset acquired
|
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
|
if acquire_lock 2>/dev/null; then
|
||||||
acquired=1
|
acquired=1
|
||||||
break
|
break
|
||||||
else
|
else
|
||||||
# POSIX sleep(1) doesn't provides time precision of subsecond
|
# POSIX sleep(1) doesn't provide subsecond precision, but many others do
|
||||||
sleep 1
|
sleep 0.1 2>/dev/null || sleep 1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue