Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
您好我正在尝试通过使用锁定文件file.flock(File::LOOK_EX)
file.flock(File::LOOK_EX)
如果无法阻止文件,它会阻止应用程序的问题。
rescue也无济于事。
rescue
flock如果第一次尝试无法锁定文件,有什么方法可以告诉失败吗?
flock
您可以添加LOCK_NB常量:
LOCK_NB
file.flock(File::LOOK_EX | File::LOCK_NB)
这将防止操作阻塞。