Exception inside contextmanager should cancel the zim creation
まだ誰も着手していません。
評価
調査の方向性
Start at the Python writer.Creator context-manager entry point and reproduce the issue with the example in the report. Trace what happens when the block raises an exception; done means creation is cancelled, temporary files are removed, and no incomplete valid ZIM file remains.
索引モデルが issue の本文から書いたものです。
説明
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.
with libzim.writer.Creator(
"test_x07.zim", main_page="A/index.html", index_language="eng", min_chunk_size=2048,
) as zfile:
zfile.add_article(DumbArticle("index.html", "hello", ARTICLE_MIME, "bonjour"))
raise Exception("outch")
zfile.add_article(DumbArticle("page2.html", "hello2", ARTICLE_MIME, "bonjour2"))
T:0; A:4; RA:0; CA:4; UA:0; FA:0; IA:1; C:0; CC:0; UC:0; WC:1
T:0; Waiting for workers
T:0; ResolveRedirectIndexes
Resolve redirect
T:0; Set article indexes
set index
T:0; Resolve mimetype
T:0; create title index
T:0; 6 title index created
T:0; 2 clusters created
T:0; write zimfile :
T:0; write mimetype list
T:0; write directory entries
T:0; write url prt list
T:0; write title index
T:0; write cluster offset list
T:0; write header
T:0; write checksum
T:0; rename tmpfile to final one.
T:0; finish
Traceback (most recent call last):
File "./demo.py", line 55, in <module>
raise Exception("outch")
Exception: outch
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 ?
- 主要言語
- Python
- スター
- 109
- フォーク
- 29
- 平均マージ
- 9日 1時間
- マージ済み PR(30日)
- 1
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
openzim/python-libzim のほかの issue
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
openzim/python-libzim#268 · コメント 4 件 · リアクション 1 件 ·
-
Release 3.14.0 オープンtask
openzim/python-libzim#267 · 担当者 1 名 ·
-
Code review: writer-path use-after-free, sys.modules corruption, GIL held across all reader I/O オープン
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
openzim/python-libzim#266 ·
-
Build for ABI3 オープンenhancement
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
openzim/python-libzim#264 · コメント 1 件 ·
-
enhancement upstream
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
openzim/python-libzim#241 ·
openzim/python-libzim の issue をすべて見る
似ている issue
-
area: harness bug status: needs-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
Human-Agent-Society/reef#625 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 80/100
learningequality/kolibri#15351 · コメント 2 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
Name consistency オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
eellak/triplestore#65 · コメント 1 件 ·