[rubygems/rubygems] Print message when blocking on a file lock.

https://github.com/rubygems/rubygems/commit/3ca7ef214c
This commit is contained in:
Ellen Marie Dash 2024-11-27 18:13:56 -05:00 committed by Hiroshi SHIBATA
parent df534ef0fc
commit 7389ca87b3
Notes: git 2025-01-14 03:25:02 +00:00

View File

@ -815,7 +815,14 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
File.open(path, mode) do |io|
begin
io.flock(File::LOCK_EX)
# Try to get a lock without blocking.
# If we do, the file is locked.
# Otherwise, explain why we're waiting and get a lock, but block this time.
if io.flock(File::LOCK_EX | File::LOCK_NB) != 0
warn "Waiting for another process to let go of lock: #{path}"
io.flock(File::LOCK_EX)
end
io.puts(Process.pid)
rescue Errno::ENOSYS, Errno::ENOTSUP
end
yield io