Skip to content

Add ASGI pathsend extension support #346

@Archmonger

Description

@Archmonger

Currently, ASGI applications must read and send each file chunk in Python to transmit file data. This is inefficient since it steals a lot of GIL time for something that is an IO-bound task.

Pure-python ASGI webservers could implement pathsend as something akin to asyncio.to_thread( os.sendfile, ... ). When wrapping the operating system's syscall in a thread, it would would free up a ton of GIL time, especially for multiple concurrent huge payloads.

If os.sendfile doesn't exist (such as on Windows) then it would need to fall-back to traditional python chunking.

I can PR this behavior, just let me know if you agree.

Ref:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions