Open rgaudin opened 4 years ago
Yes. However, there is no proper way to cancel the zim creation on libzim side itself.
I've just open a issue on libzim side : openzim/libzim#347
@mgautierfr, I tested the thread_exception
branch on libzim but I see no difference in how an exception in a ContentProvider is handled"
def test_creator_exception_item(fpath):
class AContentProvider:
def get_size(self):
return 1
def feed(self):
raise FileNotFoundError("missing file")
class AnItemWithCP(StaticItem):
def get_contentprovider(self):
return AContentProvider()
with Creator(fpath) as c:
with pytest.raises(RuntimeError, match="FileNotFoundError"):
c.add_item(AnItemWithCP())
It crashes with an output similar to:
Resolve redirect
set index
libc++abi.dylib: terminating with uncaught exception of type std::runtime_error: Traceback (most recent call last):
File "libzim/wrapper.pyx", line 127, in libzim.wrapper.blob_cy_call_fct
blob = func()
File "/Users/reg/src/pylibzim/tests/test_libzim_creator.py", line 132, in feed
raise FileNotFoundError("missing file")
FileNotFoundError: missing file
Fatal Python error: Aborted
What's different though is that a lot of the tests are now failing with the obscure RuntimeError: Creator is in error state
yet still crashing the process.
This issue has been automatically marked as stale because it has not had recent activity. It will be now be reviewed manually. Thank you for your contributions.
This issue has been automatically marked as stale because it has not had recent activity. It will be now be reviewed manually. Thank you for your contributions.
When using the context-manager, should a (non libzim) error occur, the exception is raised but the finalization is done on the Creator as if everything went well.
This results in a valid ZIM file on the filesystem but lacking the second article of course.
I think the expected behavior would be to cancel the ZIM creation and remove temporary files.
@mgautierfr @kelson42 ?