使用什么 CPAN 模块通过 Perl 进行非阻塞文件锁定
我想确保一次只运行一个进程。所以我想确保 jobB 不会运行,除非 jobA 没有运行。
如果它能够重试锁定,那就太好了,这样我就不必编写代码了。大概是这样的:
LockFileModule->lock(
lockfile => '/fabulous/pants',
retries => 12,
timeout => 25,
timebetweenretries => 30,
) or die "the other job is still running";
在 Perl 中执行此操作的最佳方法是什么?我希望有一个很好的 CPAN 模块来解决这个问题。
I want to make sure only one process at a time runs. So I want to make sure jobB doesn't run unless jobA is not running.
It would be great if it had some ability to retry the lock so I don't have to code that. Something vaguely like this:
LockFileModule->lock(
lockfile => '/fabulous/pants',
retries => 12,
timeout => 25,
timebetweenretries => 30,
) or die "the other job is still running";
Whats the best way to do this in Perl? I'm hoping there is a good CPAN module for this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这将锁定程序本身的DATA部分。我使用这种技术,效果非常好。
您可以扩展它以非常轻松地启用重试。
This will lock the DATA section of the program itself. I use this technique, and it works very well.
You can expand it to enable retries pretty easily.