-
Notifications
You must be signed in to change notification settings - Fork 337
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python ASGI: support bytearray, memoryview in response body #648
Labels
z-enhancement ⬆️
Product Enhancement
Comments
Hi @filiphanes, Thank you for your report. Could you please try following patch with bytearray support if it works for you:
|
andrey-zelenkov
added a commit
to andrey-zelenkov/unit
that referenced
this issue
Jan 26, 2024
Partially solves the problem: nginx#648
andrey-zelenkov
added a commit
to andrey-zelenkov/unit
that referenced
this issue
Jan 30, 2024
@filiphanes requested support for bytearray and memoryview in the request body here: nginx#648 This patch implements bytearray body support only. Memoryview body still need to be implemented.
andrey-zelenkov
added a commit
to andrey-zelenkov/unit
that referenced
this issue
Feb 9, 2024
@filiphanes requested support for bytearray and memoryview in the request body here: <nginx#648> This patch implements bytearray body support only. Memoryview body still need to be implemented.
andrey-zelenkov
added a commit
that referenced
this issue
Feb 21, 2024
@filiphanes requested support for bytearray and memoryview in the request body here: <#648> This patch implements bytearray body support only. Memoryview body still need to be implemented.
andrey-zelenkov
added a commit
that referenced
this issue
Feb 27, 2024
@filiphanes requested support for bytearray and memoryview in the request body here: <#648> This patch implements bytearray body support only. Memoryview body still need to be implemented.
pkillarjun
pushed a commit
to pkillarjun/unit
that referenced
this issue
May 29, 2024
@filiphanes requested support for bytearray and memoryview in the request body here: <nginx#648> This patch implements bytearray body support only. Memoryview body still need to be implemented.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When sending ASGI response:
Nginx Unit currently allows body to be only
bytes
type, but Python typesbytearray
andmemoryview
could be supported, to avoid conversion to bytes and copying memory.bytearray
is faster then bytes when appending lots of small parts.memoryview
overbytes
orbytearray
objects is used to avoid memory copying.Maybe all objects with buffer protocol could be supported https://docs.python.org/3/c-api/buffer.html
Looking at file https://github.com/nginx/unit/blob/master/src/python/nxt_python_asgi_http.c
and
https://docs.python.org/3/c-api/memoryview.html
https://docs.python.org/3/c-api/bytearray.html
this should be straightforward.
Uvicorn ASGI server support these types.
The text was updated successfully, but these errors were encountered: