Ruby 在 n *毫秒* 秒后使代码块超时
在 Ruby 中,我需要在 n milli 秒后超时执行一段代码。我知道 Ruby Timeout 库支持以秒为单位的超时:
http://ruby-doc.org/stdlib/libdoc/timeout/rdoc/index.html
这可能吗?
In Ruby, I need to time out the execution of a block of code after n milli seconds. I know that the Ruby Timeout library supports timeouts in seconds:
http://ruby-doc.org/stdlib/libdoc/timeout/rdoc/index.html
Is this possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需使用十进制值作为超时值。 n 毫秒的示例:
Just use a decimal value for the timeout. Example for n milliseconds: