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

fix 793: allow custom async iterator #1041

Merged
merged 15 commits into from Oct 21, 2020
Merged

fix 793: allow custom async iterator #1041

merged 15 commits into from Oct 21, 2020

Conversation

witling
Copy link
Contributor

@witling witling commented Sep 3, 2020

When a custom async iterator is passed to StreamingResponse, the type of object is determined by inspect.isasyncgen. This method does an isinstance check against the default python iterator and therefore does not work on custom objects implementing the async iterator protocol. (Closes #793)

starlette/responses.py Outdated Show resolved Hide resolved
@uriyyo
Copy link
Contributor

uriyyo commented Sep 3, 2020

@witling Also, it will be great to add tests to cover this feature.

@witling
Copy link
Contributor Author

witling commented Sep 3, 2020

@uriyyo Thanks for the notes! I've updated my pull request.

Copy link
Contributor

@uriyyo uriyyo left a comment

Choose a reason for hiding this comment

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

Looks great for me

@witling
Copy link
Contributor Author

witling commented Sep 4, 2020

blocked by #1040

Copy link
Member

@JayH5 JayH5 left a comment

Choose a reason for hiding this comment

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

Thanks for the PR, this looks like a simple and useful improvement.

Please rebase on or merge master. The CI should pass (or at least make it further) since #1042 was merged.

tests/test_responses.py Outdated Show resolved Hide resolved
@witling
Copy link
Contributor Author

witling commented Sep 11, 2020

@JayH5 Thanks for your effort! I've updated my pr.

Copy link
Member

@JayH5 JayH5 left a comment

Choose a reason for hiding this comment

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

Suggested a few tweaks to the tests, please move the test functions further up the file to be immediately after the existing tests for streaming responses. Thanks

tests/test_responses.py Outdated Show resolved Hide resolved
tests/test_responses.py Outdated Show resolved Hide resolved
@witling
Copy link
Contributor Author

witling commented Oct 6, 2020

annotations were implemented

@witling
Copy link
Contributor Author

witling commented Oct 13, 2020

blocked by #1072

Copy link
Member

@JayH5 JayH5 left a comment

Choose a reason for hiding this comment

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

Thanks for your patience with this!

@JayH5 JayH5 merged commit a9f8821 into encode:master Oct 21, 2020
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.

StreamingResponse doesn't support PEP-492 asynchronous iterators
3 participants