mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-10-26 19:01:39 -04:00
Running gc.collect to avoid memory leak with PDF titles.
This commit is contained in:
parent
b373992fed
commit
cd96832d4f
1 changed files with 5 additions and 1 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import gc
|
||||
import pathlib
|
||||
from typing import List, Dict, Optional
|
||||
|
||||
|
|
@ -17,7 +18,10 @@ logger = logger.getChild(__name__)
|
|||
def get_pdf_title(path: pathlib.Path) -> Optional[str]:
|
||||
reader = PdfReader(path)
|
||||
if reader.metadata and reader.metadata.title:
|
||||
return reader.metadata.title.strip()
|
||||
title = reader.metadata.title.strip()
|
||||
# TODO collecting titles causes a memory leak. Why?
|
||||
gc.collect()
|
||||
return title
|
||||
|
||||
|
||||
@register_modeler
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue