Skip to content
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

Closed
wants to merge 2 commits into from

Conversation

Jeffwhen
Copy link

@Jeffwhen Jeffwhen commented May 12, 2018

#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.

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 \
Copy link
Contributor

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.
Copy link
Contributor

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

@r0fls
Copy link
Contributor

r0fls commented Jul 11, 2018

@Jeffwhen final comment: can you demonstrate how to verify this works, or add a unit test?

@sjsadowski
Copy link
Contributor

Closing as the PR author never responded to the reviewer's request and it's been 6+ months.

@sjsadowski sjsadowski closed this Sep 25, 2018
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.

3 participants