什么是“终止对象”,为什么我不能调用它的方法?
我定期收到此异常:
NotImplementedError: method `at' called on terminated object
在这行代码上:
next if Hpricot(html).at('a')
此错误意味着什么?我怎样才能避免它?
Periodically I get this exception:
NotImplementedError: method `at' called on terminated object
on this line of code:
next if Hpricot(html).at('a')
What does this error mean? How can I avoid it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您正在使用的库使用自定义 C 扩展。在 C 扩展中,它尝试调用已被垃圾收集的 Ruby 对象的方法。
这在纯 Ruby 中不会发生,因为垃圾收集器只会释放无法再从任何引用访问的对象。但在 C 中,可能会在垃圾收集器不检查的地方保留对 Ruby 对象的引用(例如,编译器可能已将变量放入 CPU 寄存器中)。
The library you are using makes use of a custom C extension. In the C extension, it is trying to call a method on a Ruby object which has already been garbage-collected.
This can't happen in pure Ruby, because the garbage collector will only free objects which are no longer accessible from any reference. But in C, it is possible to have a reference remaining to a Ruby object, in a place which the garbage collector doesn't check (for example, the compiler may have put a variable in a CPU register).
这可能是一个链接问题。检查您是否未链接该扩展两次。
It might be a linking problem. Check that you didn't link the extension twice.