Skip to content

Conversation

@JordonPhillips
Copy link
Contributor

The "clever" workaround to the crt taking a sync stream doesn't work. This effectively reverts the crt binding to the previous state of buffering everything immediately. This unfortunately means that the input stream must be closed before anything can be read. This is not a tenable state for the future.

The ideal resolution is for the crt to support reading from an async stream. We might have to contribute that support. There may be other options, like using futures... or sleep... which might be necessary. But please no.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

The "clever" workaround to the crt taking a sync stream doesn't work.
This effectively reverts the crt binding to the previous state of
buffering everything immediately. This unfortunately means that the
input stream must be closed before anything can be read. This is not
a tenable state for the future.

The ideal resolution is for the crt to support reading from an async
stream. We might have to contribute that support. There may be other
options, like using futures... or sleep... which might be necessary.
But please no.
@JordonPhillips JordonPhillips requested a review from a team as a code owner December 19, 2024 14:45
Comment on lines +304 to +308
# If the body is an async stream.... read it all into memory. This is
# very unfortunate, but necessary because the CRT doesn't currently
# have the capability to read async. We will likely have to implment
# this capability into it ourselves, or implment a thread-based wrapper.
crt_body = BytesIO(await request.consume_body_async())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we can do anything like readinto with a buffer for the CRT to avoid having to do this all at once. I'll reach out to them to see if there's anything quick we can do here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean we could ostensibly pass them an InputStream that does its own thing, but at the end of the day it's synchronous.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants