Merge pull request #5810 from okhowang/flock

use python flock firstly
This commit is contained in:
Mike McQuaid 2019-02-26 07:54:13 +00:00 committed by GitHub
commit 716c979a5f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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