Skip to content

Clarification on thread safety #4774

Description

@vikigenius

The docs say PyMuPDF does not support running on multiple threads.

I am running in async context

async def handle_request(path: str):
    await asyncio.to_thread(extract_pdf(path))
def extract_pdf(path: str):
    with pymupdf.open(path) as pdf:
        do_extract()

Is this pattern inherently unsafe because of the asyncio.to_thread? Even though no pymupdf objects are shared across thread boundaries?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions