HTML results carry a bs4 NavigableString title, so they cannot be pickled and keep the whole page in memory
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 55/100
Hướng nghiên cứu
Read the title assignments in packages/markitdown/src/markitdown/converters/_html_converter.py, _bing_serp_converter.py, _wikipedia_converter.py, and _youtube_converter.py. Convert the title to a plain string before storing it, then check that the reported HTML fixture and the supplied reproduction pickle successfully and return a plain str title from a worker.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
For HTML input, DocumentConverterResult.title is not a str. It is the bs4.element.NavigableString returned by soup.title.string. That object is still linked to the parsed document (.parent, .next_element, ...), so:
- pickling the result walks the whole DOM, and fails with
RecursionErrorfor an ordinary page. This breaksmultiprocessing/ProcessPoolExecutorworkers, and any cache that pickles results. - for small pages that do pickle, the payload is the full tree (a 21-byte Markdown result pickles to about 2.5 KB).
- every result keeps the full BeautifulSoup tree of the page alive for as long as the result lives.
The bundled fixture tests/test_files/test_wikipedia.html, converted as a plain HTML file, already fails to pickle.
Repro
import io
import pickle
import tracemalloc
from concurrent.futures import ProcessPoolExecutor
from markitdown import MarkItDown, StreamInfo
PAGE = (
"<html><head><title>Report</title></head><body>"
+ "".join(f"<p>Paragraph {i}</p>" for i in range(3000))
+ "</body></html>"
).encode()
def convert(data: bytes):
return MarkItDown().convert_stream(
io.BytesIO(data), stream_info=StreamInfo(extension=".html")
)
if __name__ == "__main__":
result = convert(PAGE)
print("title type:", type(result.title).__name__)
try:
pickle.dumps(result)
print("pickle: ok")
except RecursionError as e:
print("pickle: RecursionError:", e)
with ProcessPoolExecutor(1) as pool:
try:
print("worker:", pool.submit(convert, PAGE).result().title)
except Exception as e:
print("worker:", type(e).__name__, e)
Output on main (ed17895):
title type: NavigableString
pickle: RecursionError: maximum recursion depth exceeded
worker: RecursionError maximum recursion depth exceeded while calling a Python object
Expected
result.title is a plain str ("Report"), the result pickles, and the worker returns it.
Root cause
The title is taken straight from soup.title.string:
packages/markitdown/src/markitdown/converters/_html_converter.py:90packages/markitdown/src/markitdown/converters/_bing_serp_converter.py:119packages/markitdown/src/markitdown/converters/_wikipedia_converter.py:75(returned as is when the page has nomw-content-textbody)packages/markitdown/src/markitdown/converters/_youtube_converter.py:104
So this affects HTML files, URL conversions of web pages, Bing result pages, and the YouTube fallback title.
Fix
Copy the value with str(...) before storing it as the title. A tested fix is ready on branch chaitanya0305:fix/html-title-plain-str.
- Ngôn ngữ chính
- Python
- Star
- 198k
- Fork
- 15k
- Merge trung bình
- 2 giờ 16 phút
- Pull request đã merge (30 ngày)
- 9
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Có Dockerfile hoặc tệp Docker Compose
- Không có mẫu pull request
- Không có hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của microsoft/markitdown
-
IpynbConverter uses a comment inside a Markdown code fence as the notebook titleCó thể đã có người làm @Primaverah đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
microsoft/markitdown#2964 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
PPTX image alt text ending in a backslash breaks the Markdown imageCó thể đã có người làm @dongyikuan919 đã nhận 3 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
microsoft/markitdown#2943 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
PPTX chart labels with pipes or line breaks produce malformed Markdown tablesCó thể đã có người làm @dongyikuan919 đã nhận 5 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 92/100
microsoft/markitdown#2937 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
DOCX: math pre-processing re-parses every document.xml even without equations (32 s -> 17.5 s on a 12.5 MB document)Có thể đã có người làm @houyunsun đã nhận 26 ngày trước. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 89/100
microsoft/markitdown#2834 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
URL fetch sends default python-requests User-Agent, Wikipedia returns 403Có thể đã có người làm @sushan5140 đã nhận 31 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
microsoft/markitdown#2820 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của microsoft/markitdown
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
hugohe3/ppt-master#366 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 89/100
Maintainer thường phản hồi trong vòng 2 ngày
-
[开源推荐] 用 Claude 搭的 A 股投研与盘中作战系统Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
521xueweihan/HelloGitHub#4716 ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 84/100
pcqpcq/open-source-android-apps#619 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
contribution Windows 主机
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Lee-xeo/Claude-Cage#1519 ·
Maintainer thường phản hồi trong vòng 1 ngày