diff options
author | Ellen Marie Dash <[email protected]> | 2024-11-27 18:13:56 -0500 |
---|---|---|
committer | Hiroshi SHIBATA <[email protected]> | 2025-01-14 12:24:37 +0900 |
commit | 7389ca87b3cc9800af5560aa9e7d05ad584ed0d5 (patch) | |
tree | 19591aead2bd46469f1dcfa6c7d6172bcffba84a | |
parent | df534ef0fcdbe804ec08aaeef2b63be3e1bbd709 (diff) |
[rubygems/rubygems] Print message when blocking on a file lock.
https://github.com/rubygems/rubygems/commit/3ca7ef214c
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/12568
-rw-r--r-- | lib/rubygems.rb | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/rubygems.rb b/lib/rubygems.rb index 5951dfe05b..ef8abcb855 100644 --- a/lib/rubygems.rb +++ b/lib/rubygems.rb @@ -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 |