use python flock firstly

This commit is contained in:
okhowang(王沛文) 2018-06-22 15:51:34 +08:00
parent be70d0b62d
commit d959a780d4

View File

@ -45,12 +45,12 @@ _create_lock() {
if [[ -x "$ruby" ]] && "$ruby" -e "exit(RUBY_VERSION >= '1.8.7')"
then
"$ruby" -e "File.new($lock_fd).flock(File::LOCK_EX | File::LOCK_NB) || exit(1)"
elif [[ -x "$(type -P flock)" ]]
then
flock -n "$lock_fd"
elif [[ -x "$python" ]]
then
"$python" -c "import fcntl; fcntl.flock($lock_fd, fcntl.LOCK_EX | fcntl.LOCK_NB)"
elif [[ -x "$(type -P flock)" ]]
then
flock -n "$lock_fd"
else
onoe "Cannot create $name lock, please avoid running Homebrew in parallel."
fi