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?
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?
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.
require
the extension twice"? (Isn't require
designed to make sure this doesn't cause problems?) –
Burnie © 2022 - 2024 — McMap. All rights reserved.
Hpricot(html)
to a variable before whole loop instead of performing it every time? – Sclerosishtml
is the loop parameter, so I can't do it before the loop, though I could do something likedoc = Hpricot(html)
at the top of the loop and dodoc.at('a')
. I'll give this a try – Burnie