Skip to content

Commit a531669

Browse files
docs/faq/index.rst: new item: Can I use multithreading with PyMuPDF, perhaps with free-threading Python?
1 parent 941997d commit a531669

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

docs/faq/index.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,6 +1133,24 @@ FAQ
11331133
<div class="tip"><strong>Note:</strong> Threading with GIL release was tested but found to have intolerable overhead. Multiprocessing is the better approach for parallelism.</div>
11341134
</div>
11351135
</div>
1136+
1137+
<div class="faq">
1138+
<div class="faq-q"><span class="marker">Q</span><span class="question">Can I use multithreading with PyMuPDF, perhaps with <a href="https://docs.python.org/3/howto/free-threading-python.html">free-threading Python</a>?</span><span class="toggle">+</span></div>
1139+
<div class="faq-a">
1140+
<p>No, PyMuPDF does not support multithreaded use,
1141+
even with newer free-thread Python.
1142+
1143+
<p>Making PyMuPDF work with threads is a tricky problem.
1144+
The underlying MuPDF library only provides partial thread safety so the results would not be as performant as might be naively assumed,
1145+
and the implementation would inevitably introduce and expose subtle bugs.
1146+
1147+
<p>Any thread-safe implementation of PyMuPDF would also necessarily impose a single-threaded overhead.
1148+
1149+
<p>The preferred approach is to <a href="../recipes-multiprocessing.html">use multiple processes instead of multiple threads</a>.
1150+
This gives most of what is generally required,
1151+
with simplicity and guaranteed correctness.
1152+
</div>
1153+
</div>
11361154

11371155
</div>
11381156

0 commit comments

Comments
 (0)