summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars-Dominik Braun <lars@6xq.net>2021-10-21 15:44:08 +0200
committerLars-Dominik Braun <lars@6xq.net>2021-10-27 15:36:58 +0200
commit5908766e9dc415b0fb97dbba57e67dba918e88d0 (patch)
tree4e74e5138717195728e6143a480c87881093947e
parent8315da395a2a99111bf3e9d0ab3846f7ddbf9732 (diff)
downloadlulua-5908766e9dc415b0fb97dbba57e67dba918e88d0.tar.gz
lulua-5908766e9dc415b0fb97dbba57e67dba918e88d0.tar.bz2
lulua-5908766e9dc415b0fb97dbba57e67dba918e88d0.zip
text: epub: Prevent memory leak
It looks like ebooklib creates non-GC-able references to ZipFile, which must be cleaned up manually.
-rw-r--r--lulua/text.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/lulua/text.py b/lulua/text.py
index 18e4dbf..ea91139 100644
--- a/lulua/text.py
+++ b/lulua/text.py
@@ -193,6 +193,10 @@ def filterEpub (item):
stream = walker (document)
s = HTMLSerializer()
yield ''.join (s.serialize (stream))
+ # It looks like ebooklib is leaking ZipFile instances somewhere, which
+ # can be prevented by resetting the book before the GC grabs it.
+ book.reset ()
+ del book
def filterText (fd):
yield fd.read ().decode ('utf-8')