-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Support flow control for request streaming #1220
Conversation
sanic/server.py
Outdated
@@ -230,6 +233,18 @@ def data_received(self, data): | |||
exception = InvalidUsage(message) | |||
self.write_error(exception) | |||
|
|||
if self.is_request_stream and not self._paused and \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we turn self.request is not None and self.request.stream and self.is_request_stream and not self._paused and
into a property? is_active_stream
for instance.
@@ -2,7 +2,7 @@ | |||
|
|||
## Request Streaming | |||
|
|||
Sanic allows you to get request data by stream, as below. When the request ends, `request.stream.get()` returns `None`. Only post, put and patch decorator have stream argument. | |||
Sanic allows you to get request data by stream, as below. When the request ends, `request.stream.get()` returns `None`. In order to do flow controll, calling `request.stream.task_done()` right after processing is required. Only post, put and patch decorator have stream argument. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick, but can you fix the typo here, controll
@Jeffwhen final comment: can you demonstrate how to verify this works, or add a unit test? |
Closing as the PR author never responded to the reviewer's request and it's been 6+ months. |
#546
This may look naïve. But I tested it, and it worked. So I thought this might be helpful. Or at least bring this issue up so somebody else might git it fixed.