Skip to content

Conversation

@rgaudin
Copy link
Member

@rgaudin rgaudin commented Jun 26, 2020

This addresses (badly I presume) the problem that users need to stop on user-code error inside Article's virtual method.
It's essential otherwise they'll endup with garbaged ZIM files.
This first commit (8ed926d) achieves that but there is probably a be a better way to do it.

--

Another related commit regards the next step in this process, being able to stop the creation process when an error occurs.
The only workaround I found was to prevent calling finalize() (node-libzim and zimwritefs exits before calling it for instance).
As we call close() and thus finalize() on __exit__ and __del__, for convenience, we have to bypass this.

It works fine in scrapers but not on the tests as the reader's tests trigger a manual garbage collection which the libzim is not happy with, as finalize() was never called…

To overcome that yet still test this important capability, I'm instanciating a new VM in the test.

@mgautierfr, please consider it a POC to start the discussion on this. We can surely opt this test out for now . Exception stuff is mandatory though.

renaud gaudin added 2 commits June 26, 2020 17:29
Upon adding an article, virtual methods get_xxx() are called on the article to retrieve data.
Should an exception be raised in this user code, it was caught and ignored.
This changes this behavior to raise a RuntimeError with an explicit message instead.
As this exception passes through Cython, we can't retrieve the actually raised exception though.
As the libzim lacks a `cancel()` method to properly stop a ZIM file creation process
without calling `finalize()` (which always creates the ZIM file), users need to cheat
the creator to not call finalize(), even upon exit (as `Creator`'s destructor do call `finalize()`)

Test instanciates a different python VM as the libzim_reader tests (manual garbage collection)
leads to a segfault.
@rgaudin rgaudin requested a review from mgautierfr June 26, 2020 17:52
@mgautierfr mgautierfr mentioned this pull request Jun 29, 2020
@rgaudin
Copy link
Member Author

rgaudin commented Jun 29, 2020

Superseeded by #56.

@rgaudin rgaudin closed this Jun 29, 2020
@rgaudin rgaudin deleted the rgaudin/forward-exc branch June 29, 2020 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants